I am planning on posting some code, but want a comment in the code that the code is under Creative Commons, would this comment be ok in the code posted at SO for an answer?

The code is by me; the algorithm is by someone else and is noted in the comments.

// Portions Copyright (C) <Year> by <Author of original answer>
// Copyright (C) <Year> by <Self>
// License: Creative Commons BY-SA Version 3.0 
// This code is derived from a StackOverflow answer by <Author of original answer>
// See: http://stackoverflow.com/a/<answer identifier>
// This code is from a StackOverflow answer by <self>
// See: http://stackoverflow.com/a/<answer identifier>


My concern is that once the code leaves SO, the code needs to keep the copyright and the Creative Commons statements. Adding the copyright I understand.

I have never put a Creative Commons statement in a piece of code and was wondering if there is a standard.


Thanks Bart, your question helped me clarify my goal.

From CreativeCommons.org:

"Licensing a work is as simple as selecting which of the six licenses best meets your goals, and then marking your work in some way so that others know that you have chosen to release the work under the terms of that license."

So it appears my comment does the job.

  • 1
    Forgive me my ignorance, but wouldn't that automatically be the case given SO's use of CC? As in, that applies to anything you post? – Bart Mar 14 '12 at 16:41
  • 5
    It's a good question, but according to the SE TOS anything shared in the network is inherently subject to the Creative Commons Attribution Share Alike license. If that differs from the CC license actually used by the code you may be in violation by sharing it. – M.Babcock Mar 14 '12 at 16:45
  • @Bart: I agree. What I am really after is that if someone copies and paste the code to another site, that the code keeps the notification. Once the code leaves SO, it needs to keep the notice. No problem with SO. – Guy Coder Mar 14 '12 at 16:45
  • 1
    When you post on Stack Exchange you agree to release it under CC-BY-SA according to Stack Exchange's attribution policy. A user could additionally wish to release it under CC-BY-SA with their own terms of attribution. Anybody reusing it would be able to chose which license terms they use. – Jeremy Banks Mar 14 '12 at 17:26
  • Given the implicit licensing of anything you post on SO as CC-BY-SA, I'm not so sure I would personally appreciate each and every snippet being prefaced by extensive copyright notices. So if you do (and you're probably perfectly in your right to do so) do it sparingly. Just my suggestion. – Bart Mar 15 '12 at 13:19
  • @Bart: I totally agree. It was for just this stackoverflow.com/a/9707421/1243762. If you check my answers you will see that this is the only one. I would put it in the wiki, but with so little rep, I have to earn rep where I can. – Guy Coder Mar 15 '12 at 13:35

To what end?

If I seriously want to use your code and not follow attribution rules, I simply just delete the notice once I have copied the code. Most smart developers won't do this. I have to agree with @Bart on this one, if you don't want people to copy your code, then don't post it. I did a quick search and can't recall any instances of this actually being asked before, but I certainly don't think this will add any value, as it can be fairly easily circumvented.

This is the internet, and unless you plan to compile the code into an obfuscated assembly, there is no way you can ever be sure someone is not going to reuse your code without the relevant copyright or attribution being given. As much as we all want to claim every person on the internet is honest, far more often is the fact that users just don't care.

For the record, when I do take code of the site, even for internal closed projects, I include a link to the actual question in my comments, so personally I am not advocating people to not give proper attribution

  • I don't have a problem with what you say; as is evident from my rep I am new here and this site has an ethos that takes some understanding. Any ideas if there is an "unofficial user guide to SO" for new people who just don’t' get all of the subtleties? – Guy Coder Mar 15 '12 at 20:07
  • 2
    I suspect that most Stack Overflow users don't think about licensing at all, and just blindly copy-paste. Shoving it in their faces may at least make some aware that there is a license... – Jeremy Banks Mar 15 '12 at 20:09

I actively oppose this (and, for that matter, your other, related suggestion) for the same reason that we dislike salutations and thanks/signature blocks at Stack Exchange: it's noisy and adds no value.

First, everything on SO is ipso facto Creative Commons-ified even if it doesn't say so and no matter where it ends up in the future. Second, and more importantly, large comment blocks take up valuable "preview space." They interfere with clean, straightforward Q&A by making it harder for people to understand the very posts that code samples are designed to enhance in the first place.

Diago's answer is right, too. Anyone who obtains your code and doesn't like the comment block can delete it in under a second.

  • I can respect your answer. I am not trying to alienate people, I am trying to make the most of this site but as a new user I keep tripping over subtleties. – Guy Coder Mar 15 '12 at 20:29
  • 3
    In short, people at SO care a lot about signal-to-noise ratio. Things like "Hi guys!" and "Thanks in advance, SuperCodeGuru9000" are considered useless fluff because they don't actually contribute to explaining the problem or the solution. An important corollary is that SO is big on specific, answerable questions. Questions that are very broad (e.g. "I am a total newbie, how can I recreate all of Facebook by the end of the week?") or poll-ish (e.g. "What's the best stack for writing a web application?") are not welcome. – Pops Mar 15 '12 at 20:36
  • @GuyCoder, Pop is right, in its current state, all you can see (without scrolling) is the extensive comments on your code, and not the code itself. And you can only see (the left) half of the comments! – Benjol Mar 16 '12 at 6:23
  • Also: welcome to SO/MSO, @GuyCoder! Just by saying "I can respect your answer," you've set yourself above half the new users who show up here. If you have other questions, and you can't find answers on Meta, feel free to post new questions or ask in chat. – Pops Mar 16 '12 at 14:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .