Suppose I have a main job (Monday to Friday, 9am to 5pm) that involves lots of computer programming, and one day I build a recommender system for my company (think of Amazon.com making recommendations). My company is in the perfume industry.

Now, I also have a part time job (8 hours a week "side gig") in the clothing industry. Based on the knowledge that I gain from my main job, I build a recommender system for this company. I make sure that I build the recommender system without looking at any of my existing code. However, because I just built the other recommender system, I am able to build this recommender system much more quickly. The code for the recommender system I built for the clothing company is also very similar to the code for the previous recommender system I built for the perfume company.

Did I do anything legally or ethically wrong?

For context, recommender systems are covered by many graduate-level computer science textbooks. They take many weeks/months to build. Code to build standard recommender systems can be found on code repositories such as GitHub, though implementation details can vary. Assume that the recommender system I built is relatively standard.

  • 2
    Comments are not for extended discussion; this conversation has been moved to chat. – Jane S Nov 13 '18 at 22:11

13 Answers 13


There is no ethical dilemna here. The simple fact that experience allows you do something more efficiently has nothing to do with ethics.

  • 36
    Agreed. @wwl did you bring any experience from previous work to your perfume company job? So long as you don't reuse documentation, code or tests from the perfume job on the clothing job, then it is the same thing. – Mawg Nov 13 '18 at 7:33
  • 26
    I would add that there is no "conflict of interest" here because the 2 companies are in entirely different industries. So don't sweat it :) – vikingsteve Nov 13 '18 at 11:19
  • 9
    Knowledge ("how" in this case, as opposed to "what") and skills gained are not intellectual property. No company can prevent you from putting those skills to use. My current employer even went so far too say that if we build a tool (eg a recommendation system), we're ok taking that code with us. It just can't have or use propriety information (eg contain or access their customer or product data). Might not be the case with you, just saying how my current employer broke things down. – Draco18s Nov 13 '18 at 15:05
  • 8
    @jkf, I don't agree with Richard Stallman about everything, but his article about the deceptive vagueness of the term "Intellectual Property" is precisely on point. With regard to your statement that "IP contained in someone's head is still IP" (and passing over the astonishing resemblance to thought police) can you try to specify whether such IP is supposed to violate (a) patent law, (b) copyright law, or (c) trademark law? – Wildcard Nov 14 '18 at 1:37
  • 4
    Agreed that if you wrote the second system from scratch it should be fine but proving that might be hard. As others have said I'd expect strong similarities between your first version of a recommender system and the second version you write. Especially if writing both are very close in time to each other. Even if you aren't trying you are still going to remember the first and major structures and even things like function names may well end up matching. Those similarities could look like you copied the original code and just tweaked it for the new use or to try and hide the copying. – Evan Steinbrenner Nov 14 '18 at 21:10

If you don't have any NDA or such similar contracts with your main gig then there is nothing legally or ethically wrong with what you are doing - the way you described it.

Sometimes people are knowledgeable in certain areas for various reasons, it doesn't make you a bad person, it is the opposite, it makes you highly desired and sought after.

On the other hand if you do have a contract stopping you from working for competitors or transfering know-how or other knowledge then you might be breaking some laws/policies - which is not in the scope of this stack.

  • 22
    You are right - just wanted to add, in this case: Public knowledge, such as things covered in textbooks or available on the internet, can not be protected by an NDA. Perfume industry is not a competitor of clothing industry. – Daniel Nov 13 '18 at 10:42
  • 8
    I agree with this. It's unethical to copy code, trade secrets, or insider knowledge. Ordinary application-building skills are none of these. This is the difference between, say, a doctor using private patient knowledge from one practice to build up a second one versus using general mad leet doctor skillz gained in the first one to deliver quality care in from the second. – Robert Columbia Nov 13 '18 at 11:03
  • 2
    @Robert Columbia : However, what counts as "copying code"? Like if you developed yourself a particular coding trick that was much appreciated, and then you go work for someone else, or work for yourself and apply that same trick - from memory , not cut-and-paste - and/or something derived from it elsewhere. Especially if it produces "substantially similar"-looking code. How bad could this be looked at in terms of your character over the long term? – The_Sympathizer Nov 14 '18 at 4:36
  • 1
    @Daniel BUT if he's building a system that competes with a similar system marketed by his employer that could be a breach of a non-competition clause in his contract rather than an NDA. I know it'd be for me. – jwenting Nov 14 '18 at 6:32
  • 3
    @The_Sympathizer Every developer has some sort of style and builds up a bag of tricks along the way. As such a person's code will generally look somewhat similar from job to job. That's perfectly normal and I'm sure it's common to other industries as well. It's kind of like how movies from a director tend to have a similar feel. Expecting anything else is too much to ask, I think. – JimmyJames Nov 14 '18 at 22:22

It is important to check your contract for things like this. Some contracts have a clause that any code written while you work for company X is owned by company X. They're likely to cede those ownership rights if you're just writing a little game or something unrelated to your main job, but in a case like this where you're writing something relevant and likely to make money for another company, there could be trouble and you'd need to discuss it with your boss before going ahead.

  • 8
    This. Check your contract and jurisdiction. In many places it's common that all code you write while you're employed (which as salaried employee is 24/7) belongs to your employer. As such you essentially can not do any programming on the side for someone else since you don't have the copyright to the code you write (not applicable in all jurisdictions, obviously). – xyious Nov 13 '18 at 15:56
  • 20
    I daresay that contracts like this are ethically much more questionable than the situation the OP asked about, but... – leftaroundabout Nov 13 '18 at 17:41
  • 3
    So if OP writes code from scratch for Company A, and Company A has said clause, then OP writes code from scratch from Company B that is very close to the same code OP wrote for Company A, but is still done from scratch, then Company A can claim that they own the code that OP wrote for Company B even though 100% of the work was done FOR Company B? I have not heard of any company having ownership of any work done by an employee of theirs that they did not remunerate the employee for. – Bardicer Nov 13 '18 at 17:52
  • 7
    @Bardicer - Sadly, the exact situation you described is legal in some places. For example, only eight US states have laws limiting what an employer can claim ownership of. It's hard to enforce these restrictions if they're too overbearing so abuse is rare, but it does still happen occasionally. – bta Nov 13 '18 at 21:41
  • 3
    @Bardicer Whichever company hired him last didn't do their due diligence, and/or the theoretical OP would be on the hook for lying to them. You cannot get into that position in the first place without violating both contracts. Who ends up owning what if someone did something like that regardless is also going to be very jurisdiction-dependent (and probably predicated on the outcome of a lawsuit). – Matthew Read Nov 13 '18 at 21:41

So there's no moral issue with using transferable skills from one job to do another. Taking the IT issue out of it for a moment, there's no issue with someone who fits boilers for the local gas utility using their knowledge of general plumbing to fix someone's bathroom taps "on the side" at the weekend.

There might be an issue if you were re-using an algorithm or specific code from the main job to work the side job (I do understand from your post that you're not), but again there's no issue with you simply being good at solving a particular type of problem easily that's occurred on your side job because you've seen a lot of it recently at your main job.

If there's enough similarities between the two jobs, you might have contractual issues, but that's a slightly different issue and it's been touched on by others.

  • 2
    If OP is the one that wrote the code at the day job, it seems probable that there will be some crossover in IP even if he writes it again without looking at the other code? – jkf Nov 13 '18 at 20:00
  • @jkf a fair point, and that's one for the lawyers. I know that I've learned enough from one project to take that experience to a new project without too much crossover and I'm taking in good faith the OP's apparent belief that while the solutions are similar, they've not taken code from one to the other. – Rob Moir Nov 13 '18 at 20:23
  • 1
    @RobMoir Your analogy with a "boiler-fixer" is misleading, because there's no creative work involved that could be subject to IP. That's the part that matters. – employee-X Nov 14 '18 at 5:03
  • You mean my analogy where I specifically set the IT (so creative IP) aspect aside first in my answer @employee-X ? That analogy where I was just looking at just the transfer of skills learned in one job to another? – Rob Moir Nov 14 '18 at 6:40
  • 1
    @RobMoir Transfer of skills is not the crux of the problem. Transfer of a creative work is. At any rate, this question is probably better suited to the Law SE – employee-X Nov 14 '18 at 17:14

I don't know where you are, but in the US the copyright on code by employees goes to the employer automatically. It's called "work-for-hire". It's very likely that, wherever you are, what you write for your employer belongs to your employer. (If you used open source software to write your contribution, this may not apply. Check with a lawyer. It's a lot cheaper than losing a lawsuit.)

This means that the software you wrote for the clothing company needs to not be a derivative work of what you wrote for the perfume company, or it's copyright infringement. Your precautions sound inadequate. Despite not looking at the previous code, your software has the same structure and is generally very similar. People have been convicted of copyright infringement for similar things, even when they didn't just write the infringed-upon work.

The software industry uses a "clean room" approach to copying, to avoid copyright problems. One team will look at the code with the functionality to be copied, and write a detailed spec. Another team will get the spec and write the new code. That way, only the ideas go from one room to the other, and there is no infringement.

This is about the legal aspects. Unless your perfume company and clothing company are competitors or potential competitors, this looks ethical to me. Unfortunately, that won't help in court.

My advice in this situation is to talk to a lawyer who specializes in copyright law. If you're in the US, the odds are that you can get a quick consultation for a reasonable fee through your local bar association. The perfume company might not care, or might not find out, or might not pursue a lawsuit for a variety of reasons. However, if they do, it could wind up being very expensive for you.

  • 1
    This is probably the best answer, no idea why it is getting downvotes -- some of the highly voted answers are downright dangerous! There's a comment suggesting that OP base his "side gig" code on some preexisting open source rather than out of his head -- maybe working this into your answer would be an improvement? – jkf Nov 13 '18 at 19:57
  • 3
    +1, I like that this hits on the fact that it unfortunately doesn't really matter if OP is in the right or not, if the company decides to pursue, it could be problematic. – helrich Nov 13 '18 at 20:06
  • @jkf I think the "there is definitely no problem with this" answers are getting upvotes because most people have a strong moral sense that he has the right to use his experience anywhere - and the question is about ethics, after all. The question of what is legally enforceable is separate from the question of what is morally right. – Brilliand Nov 13 '18 at 22:51
  • @Brilliand IDK, is "render unto Caesar" a moral concept? – jkf Nov 13 '18 at 23:36
  • 1
    @Clay07g: If it gets to a lawsuit, probably against OP and the side gig, a discovery motion would probably at least allow OP's main company to get a neutral third party to compare the source code. Going from reasonable suspicion to preponderance of the evidence in a lawsuit won't be all that difficult. It will cost money, but that could perhaps be recovered in the lawsuit. – David Thornley Nov 14 '18 at 19:22

It may be far more complicated than other answers allude to.

Depending on jurisdiction you may (IANAL, so consult your lawyer) fall foul of laws that prohibit employees from competing against the company they work for.

Markedsføringloven §23 (in danish)

Har den pågældende fået kendskab til eller fået rådighed over den erhvervsdrivendes erhvervshemmeligheder på retmæssig måde, må den pågældende ikke ubeføjet viderebringe eller benytte sådanne hemmeligheder. Forbuddet gælder i 3 år efter tjenesteforholdets, samarbejdsforholdets eller hvervets ophør.

My rewrite in english (not a direct translation, written purely from an employee's view):

If the employee has gained knowledge of or gained access to the trade secrets lawfully the emloyee may not without permission use or ditribute such trade secrets. The ban is in effect for 3 years after the employment has ended.

So if any part of the algorithm or the way it is used can be construed as a trade secret the company may be able to sue for damages or at least have a solid defense against an unlawful termination suit.

Laws like this may exist in many jurisdictions even if nothing is mentioned in the employment contract.

The concept of trade secrets does not only cover an algorithm, it also covers the fact that it is this specific algorithm that the company uses.

  • 2
    I expect "trade secrets" is the critical phrase here. It doesn't sound like the OP's "relatively standard" recommender system would be a trade secret. – Ergwun Nov 14 '18 at 11:03
  • 1
    @Ergwun It will require that the employer can claim it to be a trade secret. But the bar isn't that high, especially when it comes to a potential wrongful dismissal. A recent case in the EU has been on trademarking the taste of a particular spreadable cheese. It was found that it could not be trademarked. The recipe for the cheese is still a trade secret and an employee would still run foul off the law (in my non-lawyer opinion) by posting the recipe online even if identically recipes were already publically available. The employee knows that it is exactly that recipe that is used. – Bent Nov 14 '18 at 11:59

Did I do anything legally or ethically wrong?

Transfer of knowledge, as long it doesn't include trade secrets or actual IP, is legally OK.

Use of your time in side gigs you may wish to double-check:

  • Eight hours a week is not much - are you really containing your efforts into that time? How do support issues with your "side gig" work get resolved without impacting time on the main job?

  • Are you burning yourself out and reducing your efficiency at the other job? This is not necessarily an ethical consideration, because an employer should not have control over what you do in your spare time. However, if you get no rest at weekends, or too many late nights, then your performance could well slip at the larger job.

An employer might still fire you with cause if your performance slips, or you juggle your time too much for their comfort - it doesn't matter whether it is because you spend your time partying or on a side gig. Likewise your side gig employer might appreciate the cheap product you have made for them, but might become frustrated at low level of support you are able to provide.

Check your contracts for clauses that cover conflicts of interest in general. It would be ethically and maybe also legally wrong to be moonlighting when you have signed a written agreement to not do so. Clauses in employment contracts requiring your employer to effectively be your sole employer are relatively common, due to concerns on performance and on leaks of IP (even if you fully intend not to leak IP, your employer only has your say-so that you are not, they cannot audit the work for the other employer).

Also, do bear in mind, that although you feel within your rights to act in a certain way, and it could even be legally backed up, your employer may decide otherwise. Perhaps they are still concerned about possible loss of their IP, and would fire you or even take legal action against you. Even if you would win such a case, you may not wish to go through the process or have it affect your main career, for the sake of whatever money you can make on a 20% part time role.

Bad scenarios could be more likely if you have kept the side gig secret from your main employer. You can do a lot towards clearing whether your employer thinks this idea is ethical and legal by asking them about it. You will also get your chance to frame the possible conflict of interest as something that you will handle professionally, before it gets discovered any other way.

It is probably more important to you that your main employer has a positive view of the ethical and legal status of your side gig, than the Q&A on this site.


It sounds like you've covered your bases with regards to the ethical and legal stuff. Your knowledge as a programmer of how to make recommendation systems isn't something your main gig can 'own'. As you didn't use the code from your main employer's codebase, you're pretty much in the clear.

  • 2
    This is something I've always wondered about. If he rewrote the whole thing almost identically from memory - how could he prove he didn't just reuse the codebase? – Matadeleo Nov 13 '18 at 11:26
  • 1
    @Matadeleo there is a big difference with "from memory - i remember the classes i wrote exactly and typed it out again the same" and "from memory - i remember the parts of code i needed by rewrote it". The second will for any system thats even slightly complicated result in a different set of code, probably a better set too as it will have everything he learnt from the first one in. – J.Doe Nov 13 '18 at 13:35
  • 2
    @Matadeleo If you copy code completely or partially, that is considered a copy and derivative work. The actual technique you use doesn't matter. You could have used the "copy file" function of your computer, you could have used "copy/paste", or you could have memorized it and reproduce it elsewhere at a later time. Reproduction is reproduction all the same. – Brandin Nov 13 '18 at 18:11
  • @Matadeleo You could prove that all you were using is common programming approaches. Use examples from free courses or stack exchange. – 520 Nov 14 '18 at 10:09
  • 1
    @kleineg Algorithms are not copyrightable. A simple example is Quicksort, invented by Mr. Hoare. He does not 'own' the algorithm, although he first formulated it. If you make your own implementation, then you have the copyright on that implementation. Same for any other algorithm. – Brandin Nov 16 '18 at 19:41

I agree with all the above answers. But but I will add two more considerations: antitrust laws and conflict of interest.

Antitrust. If job A and job B are competitors, and if your country has antitrust laws, then you should evaluate if the knowledge transfer is related to prices, market strategy, etc. Ask if the knowledge transfer benefit your employer(s) at the expense of customers. Be certain you aren't breaking antitrust laws.

Conflict of interest. Decide if the knowledge transfer harms one employer. For example, if the knowledge that you are transferring is a customer list, and you want to redirect business from one company to another, especially if you own the benefited company, that seems unethical.


Check your contract of employment.

I know mine states clearly that I may not perform work for hire outside my main job. It also states that I may not engage in activities that are potentially directly or indirectly in competition with those of my employer, which would include building or maintaining a system similar to what I work on professionally for an open source project or charitable work for example.

Under either of those clauses, what you want to do would be a breach of contract with your employer, not just a ground for instant termination but also for having to pay quite a lot of money in damages to your employer.

Mind that some contracts go way beyond what's legally acceptable in such clauses, and a court might then decide to deem the clause inapplicable, but that's for lawyers and judges to decide, not for you. For example I once was offered a contract that stated that I would not be allowed to perform my profession for 10 years after leaving their employ through any means (so even if they laid me off rather than me quitting). After consultation with experts in applicable law and getting letters from them, they were forced to remove that clause.

So check your contract carefully, it's almost certainly not something you're allowed to do for a commercial entity, and possibly you won't be allowed to do it for a non-profit or other charitable work either.


If you have signed a non-compete or NDA with your main employer it could be legally troubling.

But if you had signed such contracts as part of your current job you would supposedly be compensated enough to not have to think about getting a side gig in the first place! At least you should demand significant increase in salary if any of those enter the table of negotiations. Because they will limit your future freedoms and possibilities on the job market.

From an ethical stand point...

If it would not be allowed to use knowledge you have acquired previously in new jobs, how would anyone ever manage to improve and do better stuff? I learned this in university project, maybe it would be unethical towards department to use knowledge in this new job. The education and job markets would suffer greatly if everyone had to avoid using their knowledge with respect to their former masters. Education for one would be rendered quite useless.


Experience gained during a job is yours to keep. This is understood by anyone not completely dense, because that is why they pay you more money if you have more job experience.

They can't expect you to use the experience from every other company while working for them, while simultaneously not allowing the same to happen in reverse. That would be an ethical dilemma. For them.

You did the right thing by not copying the code, because according to standard contracts, what you develop on company time is copyrighted by the company.

What you describe is, in fact, the business model of many freelancers. Develop something for one client, barely breaking even, but for the next client you will do it in half the time, bill them 3/4 and they will still be happy you did it so fast. Everyone wins.

If it is ethical there, why it would be unethical for you?


Besides the legal considerations - which some of the more skeptical answers have already touched on - I also feel this approach is a bit unethical. Having been a consultant for most of the past twenty years I would not code something similar to what I am doing for another client. The forty-ish hours per week company is apparently unaware of -and likely an unwilling party to - what amounts to subsidizing the side work.

  • 3
    It's not a subsidy. A subsidy is when one party pays to help cover the cost of something for another party, such as when people in urban areas pay higher prices for internet service to help cover the costs of deploying services to rural areas. The time and effort spend on developing the original solution was not increased by the side work, and in fact it could even result in improvements. If the OP did not do the side work, his original work would not have gone faster or been less expensive. It might even have taken longer. – barbecue Nov 14 '18 at 22:59
  • I'd argue it is a subsidy since much of the work for the side customer has been financed by the primary/first customer. Who is to say the first customer would not want to expand to the other market - which sounds not all that far fetched here. – javadba Nov 15 '18 at 0:33
  • The reason it's not a subsidy is that if the developer did not do the side project, it would not have saved time or money on the original project. No extra time or money was applied to the original project to help fund the side project. A subsidy is an additional cost paid by one party to help fund another, above and beyond the base cost. If the developer used work time and resources to do the side project then it would be a subsidy, but that's not the case here. – barbecue Nov 15 '18 at 20:00
  • Any effect on the time required on the main project is immaterial to the situation described here in which the side work having been effectively subsidized by the main one. I stand by this whole approach as moderately on the unethical side. It crosses the line a bit. – javadba Nov 15 '18 at 20:02
  • What exactly do you mean by subsidize? The OP specifically said that he did not use his company's time, money or resources to develop the side project. What exactly is the subsidy that the employer provided to the side project? – barbecue Nov 15 '18 at 20:41

protected by Jane S Nov 13 '18 at 22:11

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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