Posting Code How-To’s Online
This is something I've given quite some thought to in the recent weeks. I recently moved for a job in software development, and as I'm sure many of you can imagine, sometimes you get stuck coding and turn to your favourite search engine for advice. More often than not you'll get taken to StackOverflow, a blog post, forums/message boards and finally, official documentation.
All of this got me wondering...when you post code help via StackOverflow, or how-to's on a blog, is it done with the intention of actually distributing that code to others for use how they see fit, be it in a commercial application or a personal project the reader might be working on. I think it's a very grey area when you delve into it, after all, I wouldn't mind other people using my code in any shape or form, in fact I'd find it quite the compliment! Sure it'd be quite nice if they sent an email or left a comment to say "hey, this was just what I was looking for and I've used it for XYZ" - it's nice to know that you've been able to help someone solve something.
On the other hand, if I was being picky about this, especially as my line of work currently sees me developing in C# (and not via Mono either), I could throw licensing into the mix and say that people are free to use my code as long as they have my permission and reference that they've used it somewhere. This in turn would present a company with issues as to whether they could actually use it or not, because that kind of license would almost certainly be some sort of Open-Source license, meaning that they almost certainly wouldn't use it, because it would then mean they'd have to contend with satisfying the requirements of an Open-Source license.
I think there's several issues here that I haven't even touched upon, but it made me stop and think about it, so maybe it will provide you with some food for thought too.

October 5th, 2011 - 23:28
When you post code, you _should_ to be as explicit about the license as you can be. If you don’t care about commercial reuse then BSD or MIT or Apache license it and be done with it. Being specific about the license really helps make sure you aren’t causing problems for people whom you are trying to help by offering the code up.
And if you grab published code and use it verbatim you MUST absolutely freakinlutely be clear as to the licensing rights. Just publishing code on a blog or in a book or whatever does not put it into the public domain. At a minimum standard copyright rules apply until a license is specified which grants you the right to copy or redistribute. Copy and pasting anything at all from forum code into a commercial work without clear licensing is real litigation risk. It happens all the time, but that doesn’t change the fact that its a real risk.
October 5th, 2011 - 23:55
I agree, you should be as explicit as you can about the code, but I’d say 98% of blogs I’ve come across don’t actually have any form of license attached to the code, or mentioned throughout the post. Some may have an overall license for the content, but I’d then be willing to bet that few will look for that if the posted code solves their issue.
October 6th, 2011 - 00:17
Right and those 98% of those blogs are a copyright litigation trap waiting to be sprung on someone. It really doesn’t matter if few people understand this. Everytime _you_ lift code for reuse without knowing what the license is you’ve opened up yourself to a copyright enforcement litigation action. Potentially costly if your a corporate entity that is making a profit. And if you are doing that sort of search and copy as a paid employee to build corporate products, you’ve probably broken some explicit terms of your employment(who reads all the fine print in their employment contract anyways right?) by opening up your employer to copyright infringement litigation.
I don’t see the point your trying to make in your blog. Do people lift code off the net indiscriminately without concern for licensing? Yes. Is this a socialized norm? Yes. Is it problematic. YES! Just like sharing recipes out of cookbooks with friends or trading cross stitch patterns from a book with guys in your knitting group. Socialized norms for day-to-day behaviour are out of step with the legal statutes for copyright across all sorts of copyrighted content…not just software snippets or music or video. Copyright laws are out of step with social norms for sharing everything in the digital reproduction age.
So what if few people lifting code from a forum pay attention to the license or not? You can’t make random people act in a way which limits their personal or corporate liability when cutting and pasting code. Is that your ultimate goal? if it is, its not achievable. This is why GPL enforcement is a big deal. You can’t prevent misuse of openly available code, all you can do is enforce terms after the fact.
All you can do is make sure you are acting responsibility and set an example for others. If you have no desire to personally enforce GPL terms, then don’t license under GPL when you publish code online, publish under MIT and essentially gift it without constraint. When you see a blog that doesn’t have a clear licensing policy for code snippets, talk to the site operator about that and get them to clear it up to prevent that site from becoming a litigation trap down the road for someone.
-jef
October 6th, 2011 - 00:46
All of the UGC on StackOverflow is licensed under cc-wiki, that is, cc-by-sa-3.0: http://creativecommons.org/licenses/by-sa/3.0/
So one could argue that code can be reused as long as you abide by the terms of said license. (which is permissiveish)
Also, keep in mind while the tutorial is copyrighted by the author, following the tutorial (if you’re not copying code) may not result in a derivative work.
… and even if it did, short snippets are often too trivial to be copyrightable.
IANAL.
October 7th, 2011 - 19:12
I’m not trying to make a point, so to speak, I was merely spilling some thoughts I had in my head and seeing what kind of reaction it provoked. If it provided some food for thought for other people reading it, that’s probably a good thing too.