united-states copyright intellectual-property software open-source-software
In the US, under what circumstances can I re-write code I previously wrote but do not own?
<p>I write code for company X in the USA using popular technology Y. In the course of my job I end up developing a number of useful libraries/widgets/utilities for use within the Y ecosystem that have nothing to do with X's business product per se: they are broadly useful across many applications. Some of these libraries/widgets/utilities are trivial to write, while others are elaborate and have taken months of work. The commonality is that none of them require any proprietary technology or information to function or to develop: any of them could be written by any Y developer sufficiently skilled and motivated.</p>
<p>The code I wrote is work made-for-hire and belongs to company X; let's take it as a given that I can't use or publish this specific source code outside the company. (Let's further assume that none of the code is patented.) Who owns the ideas, the knowledge of how these libraries work? If I need to solve the same problem again (or if I just want to publish open-source code), how close can my solution come to the original?</p>
<p>There are a number of related questions out there on Stack Exchange and elsewhere:</p>
<ul>
<li><a href="https://softwareengineering.stackexchange.com/questions/131103/how-can-i-reuse-generic-code-for-consulting-between-companies">How can I reuse generic code for consulting between companies?</a></li>
<li><a href="https://workplace.stackexchange.com/questions/129191/can-i-rewrite-code-i-wrote-for-a-company-for-myself-or-others-from-scratch">Can I rewrite code I wrote for a company from scratch?</a></li>
<li><a href="https://workplace.stackexchange.com/questions/129053/can-i-adapt-code-i-wrote-for-work-and-release-it-as-open-source">Can I adapt code I wrote for work and release it as open source?</a></li>
<li><a href="http://www.brightjourney.com/q/working-company-intellectual-property-rights-stuff-spare-time" rel="nofollow noreferrer">Does a company have IP rights to the stuff I do in my spare time?</a></li>
</ul>
<p>There are some very helpful answers in all those threads, but none of them really cover all the bases. I'm hoping this answer can be definitive by considering all the dimensions:</p>
<h3>Similarity to original</h3>
<ul>
<li>What if the new code (presumably, in the case of something simple) comes out <em>exactly</em> the same (even if I rewrite it without looking)?</li>
<li>What if the new code comes out <em>almost</em> exactly the same?</li>
<li>What if the code achieves precisely the same function -- i.e., produces exactly the same outputs for the same inputs -- but works substantially differently?</li>
<li>What if I change variable names or otherwise obfuscate the code purely to avoid copyright infringement, without changing the functionality?</li>
</ul>
<h3>Circumstances under which the new code is derived</h3>
<ul>
<li>What if I copy-and-paste from the original, but update a bunch of stuff so that the algorithm / architecture / etc. is substantially different?</li>
<li>What if I look at the original code in one window while I re-type it verbatim in another?</li>
<li>What if I look at the original code as a reference but substantially change things as I re-write?</li>
<li>What if I don't look at the original at all, but it still comes out extremely close to the original?</li>
<li>What if I have a photographic memory and reproduce the entire code verbatim without looking?</li>
</ul>
<h3>Complexity</h3>
<ul>
<li>What if the code is very complex and requires considerable engineering effort?</li>
<li>What if the code is simple and requires little time to reproduce once you know how it works?</li>
</ul>
<h3>Timing</h3>
<ul>
<li>What if I rewrite the code immediately after leaving company X?</li>
<li>What if I rewrite the code on nights and weekends while I'm still employed by company X?</li>
<li>What if I rewrite it N years later?</li>
</ul>
<p>There may well be other dimensions I'm forgetting -- feel free to suggest them! My question is specifically about U.S. law, but illustrative points from other countries are welcome. I don't want to narrow the scope of the question to a single state within the US, so pointing out what is universal and what might differ between states would be very helpful.</p>

<h3>Assumptions</h3>
<p>Let us assume that the code involved was created during the period of employment, was within the scope of that employment, and was validly work-made-for-hire (WFH). In that case, the code copyright is owned by the former employer.dn the person who wrote it has no more rights than a random stranger would. I am also going to assume US law.</p>
<h3>Ownership of Ideas</h3>
<blockquote>
<p>Who owns the ideas, the knowledge of how these libraries work?</p>
</blockquote>
<p>No one does. In the absence of a patent, no one ever &quot;owns&quot; an idea. ]17 USC 102(b)](<a href="https://copyright.gov/title17/92chap1.html#102" rel="noreferrer">https://copyright.gov/title17/92chap1.html#102</a>) provides:</p>
<blockquote>
<p>(b) In no case does copyright protection for an original work of authorship extend to any idea, procedure, process, system, method of operation, concept, principle, or discovery, regardless of the form in which it is described, explained, illustrated, or embodied in such work.</p>
</blockquote>
<h3>Derivative Works</h3>
<p>Copyright law does prohibit anyone making a <em><strong>derivative</strong></em> work from a work protected by copyright without the permission of the owner. A <strong>derivative work</strong> is one &quot;based on&quot; the source work. The classic case is a translation. Exactly when a piece of software is a derivative work  of another is fact-dependent. Bu several things are clear.</p>
<ul>
<li><p>If the source work is trivial and obvious, ther may not be sufficient &quot;originality&quot; for the source work to be protected by copyright at all. If the source work is not protected by a valid copyright, nothing is a derivative work of it. A &quot;hello world&quot; program, for example, is probably not original enough for any copyright. A straight-forward implementation of a basic algorithm like quicksort is probably not original enough, either.</p>
</li>
<li><p>If there is only one way, or only a small number of ways, to express the ideas of the source work, the <em><strong>merger doctrine</strong></em> applies. This means that the expression of the work is merged into the idea, leaving the expression unprotected. When the merger doctrine applies, there is, in effect, no copyright.</p>
</li>
<li><p>If a work copies ideas from a source, but none of its particular expression of those ideas, the result is not a derivative work, and is not an infringement of copyright.</p>
</li>
<li><p>If a work is definitive, but is also a <em><strong>fair use</strong></em> of the source work, it is not an infringement. The usual four-factor fir use analysis must be made to determine this. In particular, if a work is highly transformative, it is likey to be found to be a fair use.</p>
</li>
</ul>
<h3>Issues from the Question</h3>
<blockquote>
<ul>
<li>What if the new code (presumably, in the case of something simple) comes out exactly the same (even if I rewrite it without looking)?</li>
</ul>
</blockquote>
<p>That Rather suggests that the work was too trivial to be original enough to have copyright protection at all, or else that there are only a few ways to express the idea, and the merger doctrine applies. But if neither o those were true, this might be an infringement.</p>
<p>[* To be coninued*]</p>
