I think it is a fair assumption that a large number of people using Stack Overflow and other programming SE sites don't understand or don't even think about the implications of the license when using code from a post. With the current CC license they're far from obvious, but it is getting better with the proposed license change to the MIT license. But I still suspect that there is a large number of users that don't even think about attribution when copying code.

To make it easier for people that actually want to attribute code properly, but simply forget about it or don't know exactly how they should do it, I propose to add a button to code blocks that puts the code with the proper attribution into the clipboard.

This would also make it more obvious that code is under a different license than the rest of the post. An indicator for the license would also help to distinguish old and new posts that are license under different licenses after the switch.

Obviously this would have to guess the proper format for comments from the tags on the question, which will fail occasionally. But anyone that can't fix this kind of issue probably shouldn't be copy&pasting code anyway.

I know that adding something to the contents of the clipboard automatically can be seriously annoying, that is why I propose an extra button instead of doing it automatically. Anyone just selecting a piece of code and copying it would still get the code only, without attribution.

Maybe this should only appear on hover, to reduce the visual clutter it otherwise introduces. I'm more thinking about a small icon in the top right of a code block, reasonably unobtrusive.

The main purpose would be educational, to make more users aware of the license of the code here, so that they can follow it properly. Instead of this active mechanism, just a small icon in code block indicating the license with a link to the explanation might work as well.


Perhaps we should consider improvements to the posting interface as well:

  1. More explicit ways to say "This is code, and thus covered under the code license." Just using code formatting as a determination seems too likely to include content that shouldn't be included, and leave out content that should.

  2. A way to (easily) say "this is code, and I'm releasing it to the public domain / waiving my right to require attribution". Sometimes the poster may not want to burden the user with even the minimal requirements of the default license.

You must log in to answer this question.

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