I think you should be very careful about doing this without an explicitly stated license with reasonable proof of author copyright for the code snippet. It's one of the things that can easily compromise the legal security of a codebase.
I think you should be very careful about doing this without an explicitly stated license with reasonable proof of author copyright for the code snippet. It's one of the things that can easily compromise the legal security of a codebase.
http://blog.stackoverflow.com/2009/06/stack-overflow-creativ...
When I copy code verbatim from SO or another "help" site, I generally put a comment right above that chunk of code, something like:
/* See: http://stackoverflow.com/a/xxxxxxxxxxx */
Don't know if that's enough to protect against any ownership claims though.Often times code taken from SO solves the problem but noticeably is structured differently from the rest of the codebase--often with good reason--and this helps the new dev go look back at the SO conversation and see what problems this is solving / if it can be removed.
Fair use is a pretty subjective thing that's up to a judge to determine. It's a four-factor test, and you can read more here: http://fairuse.stanford.edu/overview/fair-use/four-factors/
* the purpose and character of your use
* the nature of the copyrighted work
* the amount and substantiality of the portion taken, and
* the effect of the use upon the potential market.
The fact that it's 2-4 lines may come in as part of factor 3, but the other factors also need to be taken into account.
If something I wrote, even just a few lines, is used to generate profit for someone else, and I did not permit that or place it in the public domain, I'm not sure a fair use claim would hold up. IANAL.
For example, the first factor (purpose and character; transformative nature of the work) is often less transformative in commercial settings. The fourth factor (the effect of the use upon the potential market) is also often more challenging for commercial enterprises to get past.
However, there are plenty of commercial enterprises that rely on fair use regularly. News media is a very common commercial product that relies on fair use.
Copyright and fair use law is pretty much the same for commercial and personal products. If you can make a compelling case to a judge around those four-factors, it can be fair use.
However, when taking clippings from SO and using them directly in a software, you're going to have very hard time making a fair use claim — wether it's for a personal or commercial project.