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.
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?
There are a number of related questions out there on Stack Exchange and elsewhere:
- How can I reuse generic code for consulting between companies?
- Can I rewrite code I wrote for a company from scratch?
- Can I adapt code I wrote for work and release it as open source?
- Does a company have IP rights to the stuff I do in my spare time?
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:
Similarity to original
- What if the new code (presumably, in the case of something simple) comes out exactly the same (even if I rewrite it without looking)?
- What if the new code comes out almost exactly the same?
- What if the code achieves precisely the same function -- i.e., produces exactly the same outputs for the same inputs -- but works substantially differently?
- What if I change variable names or otherwise obfuscate the code purely to avoid copyright infringement, without changing the functionality?
Circumstances under which the new code is derived
- What if I copy-and-paste from the original, but update a bunch of stuff so that the algorithm / architecture / etc. is substantially different?
- What if I look at the original code in one window while I re-type it verbatim in another?
- What if I look at the original code as a reference but substantially change things as I re-write?
- What if I don't look at the original at all, but it still comes out extremely close to the original?
- What if I have a photographic memory and reproduce the entire code verbatim without looking?
Complexity
- What if the code is very complex and requires considerable engineering effort?
- What if the code is simple and requires little time to reproduce once you know how it works?
Timing
- What if I rewrite the code immediately after leaving company X?
- What if I rewrite the code on nights and weekends while I'm still employed by company X?
- What if I rewrite it N years later?
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.