My employer asked me to code a simple algorithm from a general description published by someone on the Internet (no code/pseudocode, just plain words and pictures). So to clarify, it's not my employer's invention. I guess the algorithmic idea isn't patented either.

Now let's imagine I want to use that algorithm for my own purposes. The thing is that my way of thinking is still mine, I remember my code quite well down to the variable names, so if I'll rewrite it from scratch, chances are that it will be almost identical to my work version.

I don't plan to publish this bit of code but use in my project. Should I deliberately introduce changes to my version just in case, even if they're unnecessary and impact code clarity?

  • 2
    In principle, you're appropriating work that belongs to your employer for your own use. In practice, that code is not going to look the same, especially if you only wrote it once. You'll change it, improve it, etc., unless the algorithm is trivial, in which case its similarity isn't going to matter anyway. Mar 28, 2015 at 0:41
  • 4
    Deliberately introduce changes that improve code clarity. I'm only half-joking. Virtually everything can be made clearer and doing so puts you in a win/win situation.
    – user7043
    Mar 28, 2015 at 0:41
  • Legal advice like this should never be taken from the internet. Not even from people with high programming reputation. In my understanding, copyright applies the concrete expression of an idea, while the idea itself is not subject to its protection, so your employer would own the original program text, not the algorithm. But this is disputed and shifting and I might be terribly wrong, so you should definitely not base any dangerous decisions on this advice. Mar 28, 2015 at 6:28
  • @delnan has it right. change some variable names, maybe change the order of some instructions, if it doesn't matter. but just write another cleaner version of the algorithm and let it live on your personal laptop somewhere. keep your mouth shut about the previous version (that is your employer's code) if you ever make use of the basic idea (that your employer doesn't own) again somewhere else. Mar 29, 2015 at 4:19

1 Answer 1


Your code will be identifiable

Your coding style is going to be a little bit unique, distinct and recognizable no matter what you're programming, whether you're doing it for your employer now, or for yourself or a different employer later. So don't kid yourself that you can switch up a few variable names and make it look like different code. But that probably isn't the issue.

IP Ownership

If your employer pulled a description of the algorithm off the Internet, then your employer obviously doesn't own any IP in the idea, but they still own your work product if it is work for hire. Your work product is the digital copy of the specific code you produced for them, or printouts of the same.

They probably can't prohibit you from writing your own independent implementation of an algorithm where the original IP doesn't even belong to them. In fact, are you 100% certain your employer had a right to the IP themselves? ;-)

Work For Hire

If you are a W-2 employee you are by definition producing "work for hire" in which you have relinquished rights and ownership of your work product to your employer. I don't know who could guarantee that a good IP attorney couldn't make the case that a re-implementation from memory is materially the same thing as the original tangible work product.

If you're an independent contractor (1099), then this is going to depend on your contract. If your contract says it's work for hire, your employer owns the work product. If not, then your employer owns a perpetual license to use the work you produced, but you retain the copyright yourself, in which case you can do whatever suits you including selling the code you produced either on its own or as a part of your own product.

CAVEAT: I am not an IP attorney. But the law isn't all that obtuse on the subject.

Statutory Employee

Be aware that you could potentially be declared an employee retroactively, and your work declared to be work for hire if the employer controls your schedule, controls where you are able to do the work, controls the equipment you use, controls whether you can hire assistants or have to do all the work yourself, if the relationship is very long-term, if the employer pays you benefits that are normally considered to be regular full-time employee benefits, and so on.


Is it such a generic algorithm that it can be used in totally different, non-competing applications? Or are you privately developing a product (of which the code in question is a component) which would compete with your employer's product? If so, quit your job with your employer now and eliminate your conflict of interest. Developing a competing product while working for your employer is ethically slippery, and might be legally actionable.

If your product is something unrelated, I probably wouldn't get worked up about it, unless you have some kind of restrictive employment agreement in place.

Employment Agreements

Did you sign a highly restrictive employment agreement, NDA, IP agreement or non-compete? That's going to vary by employer. In a job for an AT&T subsidiary once long ago I basically had to sign an agreement that said every stray thought I had any time of the day or night whether I was awake or dreaming, at the office, at home or on vacation, was their property as long as I was their employee and for something like six months after my employment with them ended, that if I developed a product even years after leaving them and they could prove that I had the idea for the product while in their employ that they would own that product and I would assist them in their legal effort to secure that ownership. There wasn't any provision that said the idea would only belong to them if it pertained to a line of business they were in at the time I had the idea. The agreement also said that I wouldn't take a job for anybody doing any of the same things they did for at least two years after termination of my employment.

The two-year non-compete was about keeping my knowledge, insights and experience obtained while working for them from being useful for anybody else and would have applied to working for myself, as well. Of course as a lifetime progresses, people acquire knowledge and insights from all kinds of sources that they take to their employer, rather than obtaining from their employer, especially in the Internet age. So I think proving the true genesis of any idea or technique can be genuinely trickier now than, say, 25 or 30 years ago.

In retrospect, I feel that kind of agreement is somewhat less than 100% ethical or fair, and I feel I was too young and dumb to realize they weren't paying me anywhere remotely close enough for a no-stakes wage-only position to deserve to have me sign an agreement like that. But it was what it was, I signed it, it was legal and I needed the work and experience and in the end I'm pretty sure my employer and I benefited each other mutually.

But the work for hire statutes apply regardless of the specific employment agreement(s) you sign.

Burning Bridges, Poking Bears

In general, intact bridges produce more opportunities than burned ones, and life is long and varied and you never know when you're going to encounter a potential opportunity with the same old employer, or with one of their friends or associates. If you go around poking bears, sooner or later one of 'em is going to bite you.

Do you think you might be able to approach your employer and just ask if they'd be okay with you rewriting this bit of code (not just copying what you wrote for them), for your own unrelated purposes, on your own time, at your own place, using your own equipment?

  • That is a good, concise comparison of "work for hire" and "contractor." Very crucial when it comes to IP law and individual content creators.
    – user22815
    Mar 29, 2015 at 2:15
  • Thank you for your elaborate answer. I see it depends on my work agreement, need to re-check it, but AFAIR it's not overly restrictive (work for hire, but no ownership of thoughts and post-employment competition ban). Actually, it's a bit more complicated because the project of my employer was partially inspired by my own uni research done before I was hired. In the research I concluded there may be an algorithm, my project leader found an existing one online, I implemented it in code.
    – pati
    Mar 30, 2015 at 11:29
  • In that case I'd check and double-check to make sure you didn't give away your research when you took the job, as well (or to make sure you don't give it away in the future). Unless you're presented with the right kind of compensation to make you want to give it away. Honestly, you might want to consult with a patent/IP attorney. But it sounds as if you likely own at least some of the IP that your employer is benefiting from, or at least that if there is a prior implementation neither your employer nor you have an exclusive. The WFH (work for hire) thing still applies. Good luck! ;-) Mar 30, 2015 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.