copyright creative-commons
Attribution in Stack Overflow
<blockquote>
  <p>Please Read this: <a href="https://meta.stackexchange.com/questions/271080/the-mit-license-clarity-on-using-code-on-stack-overflow-and-stack-exchange/271113#271113">The MIT License – Clarity on Using Code on Stack Overflow and Stack Exchange</a></p>
</blockquote>

<p>All the content in Stack Overflow and other Stack Exchange (even this question) is under <a href="http://creativecommons.org/licenses/by-sa/3.0/" rel="nofollow noreferrer">Creative Commons BY-SA 3.0</a> with attribution required, so you might find this questions interesting:</p>

<p>When is attribution required?</p>

<p>The article <a href="http://blog.stackoverflow.com/2009/06/attribution-required/"><em>Attribution Required</em></a> from <a href="http://blog.stackoverflow.com/authors/jeffatwood/">Jeff Atwood</a> explains how you need to give attribution, however when you read it, looks like is talking when you republish a content from Stack Overflow or other Stack Exchange in a website or blog in any public manner, but what if I'm using code from an answer or question in my own code that is intended to be sold? How attribution should be done? Is needed? Also what if I'm just using small pieces of code that I learned or copied and paste it from an answer or question and I adapt it to my own code? Is attribution needed?</p>

<p>If you had read the license, it says that is ShareAlike this means that "If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original." In some way you might think that if you use small pieces of code from an answer or question now your work needs to be licensed under Creative Commons BY-SA 3.0 too, but when I read the <a href="https://wiki.creativecommons.org/wiki/ShareAlike_interpretation" rel="nofollow noreferrer">ShareAlike Interpretation</a> I saw this: </p>

<blockquote>
  <p>The ShareAlike condition applies only for works considered adaptations under copyright law, not simply in collections with other works (also referred to as mere aggregations).</p>
</blockquote>

<p>So it means that even if you use small pieces of code from answer or questions, your entire work doesn't need to be licensed under Creative Commons BY-SA, too, at least it be an <a href="https://wiki.creativecommons.org/index.php/Frequently_Asked_Questions#When_is_my_use_considered_an_adaptation.3F" rel="nofollow noreferrer">adaptation</a> from it not just small pieces of code, am I right?</p>

<p>First off, you need to determine whether the code is even eligible for copyright. Something like this probably doesn't cut it:</p>

<pre><code>public class HelloWorld 
{
    public static void sayHi() 
    {
        System.out.println("Why hello there!");
    }
}
</code></pre>

<p>I use Stack Overflow answers all the time. I don't copy the code directly, but I take the ideas and rewrite them for use in my own implementations. </p>

<p>With Creative Commons, it's tricky. <a href="https://opensource.stackexchange.com/questions/1717/why-is-cc-by-sa-discouraged-for-code">It's known that CC BY-SA is highly discouraged for code</a>, and this is the reason why Stack Exchange is having this licensing drama: to help end users, and contributors to stay in the clear.</p>

<p>To answer your question, you need to look at a few key components:</p>

<ul>
<li>Are you implementing your own version of the snippet?</li>
<li>Is your entire program based on that code in the SO Answer?</li>
</ul>

<p>If you answered "yes" to the first question, then no. You probably don't have to worry about licensing. While you could have a section in your program to attribute them (I keep a comment, or a little section in a file to say Thanks), that's just about as much as you need to do.</p>

<p>If you answered "yes" to the second question, then you've probably got a problem. Remember that snippet I made above? Suppose it was somewhat more complex, and it was a full, working problem. If you make changes where without my code, your program wouldn't be running, then you're probably creating an adaptation based on my work. You'd probably have to license that under the Attribution Share-Alike license.</p>

<hr>

<p>To summarize, your over thinking it. Just say thanks, be sane and don't directly cope code, and you're in the clear. Happy coding :)</p>
