Can I Use Example Code from Internet Q&A Sites?

A user recently asked:

Scenario:

  • A developer is working on a project and encounters a problem.
  • They ask a question on the internet somewhere (ie stackoverflow.com)
  • Someone answers their question and provides a nice code snippet that just about does what they want.

Where does one legally stand if the developer includes the code verbatim in their project’s code?

I know I’ve done this before…and I’m sure others have too…but I’d really like to know what the legal or ethical answer is to this question.

Note: never make business decisions based on legal advice you read on the internet — including mine! Confirm this with a qualified legal professional.

StackOverflow seems to offer its content under the Creative Commons Attribution-Share Alike 2.5 license. See the logo and link at the bottom of the page.

This means you are free to copy, distribute, and transmit any content you see here, or to remix or adapt the content.

However, you must attribute the work in the manner specified by the author (though I can’t find where this is specified on StackOverflow), and if you alter or build upon the content, you may distribute it only under a compatible license. So it’s similar to LGPL, in that respect.

I would recommend that you do not copy code or other content from StackOverflow verbatim, if you need to use it in a commercial project.

  • Should one use the example code and move on?

    No. You need to be aware of the license and comply with it, or in theory you could get your project into trouble. Realistically, this is very unlikely. But it is still possible to cause problems.

  • Should one use the example code and provide a comment referencing its origin?

    Yes, attribution is required by the Creative Commons license used by StackOverflow.

  • Should one inform the provider of the example code that they’ve used their code?

    You are not obligated to do so, so it would be a courtesy and that’s up to you.

  • Should one not use the example code at all and use the basic idea to create your own code?

    Yes, this would be a conservative and safe policy. Plus, it’s always better to understand how the code works, which you would have to in order to write code with similar functionality.

  • Is it ok to use said example code in proprietary closed-source projects?

    No. The license would require you to make your project available under the same Creative Commons Share Alike (or compatible) license.

  • Is it ok to use said example code in proprietary but internal-use-only projects?

    Technically, yes, because like GPL & LGPL, the licensing requirement only activates when you distribute a derived work. But how can you be sure that code from the internal-use-only project will never be duplicated into a product that gets distributed? Do you plan to annotate code fragments within your internal projects? I would not recommend relying on this.

  • Are the legal implications currently undefined?

    No, they are spelled out in the Creative Commons license mentioned above.

I’m posting to my blog the questions I’ve answered on StackOverflow, which earned the “Good Answer” badge. This was my answer to “What legal issues can I run into if I use example code (say from stackoverflow) in my projects?


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.