Why to NOT copy your old code?

I don’t know how common it is, but common or not, it’s still a bad idea — I found a great article at Programmers Stack Exchange about copying code, you wrote for your old employer, when leaving him for a new job. I found arguments given in this article so enlightening, that I actually decided to… copy them to my blog. So, here it is.

Programmers often operate in the mindset that solving the same problem twice is a waste of time. We try to design our code to be reusable (sometimes). We build libraries of classes and functions to reuse at some point in the future. We sometimes even give our code away so that nobody else will ever have to write code to solve the same problem that we just did. So it may be understandable to want to take “your” code with you when you move from one job to another. But you still shouldn’t do it, for the following reasons:

1. It’s not your code to take. The code you wrote for your former employer is part of the business they built. Their code is part of their competitive advantage. Sure, competitors could write their own code to solve the same problem, but they shouldn’t get the advantage of building on work that your employer paid for, owns, and didn’t authorize you to take.

2. If they have any sense at all, your new employer doesn’t want any part of the code that you took from your former employer. The more you “refer” to work you did for some previous employer, the more you put your new employer in legal jeopardy.

3. If you ever accidentally let it slip at New Employer that you’ve still got a copy of the stuff you did for Old Employer, your boss at New will probably realize that you’ll take a copy of their code when you leave for some other job. That might not sit well with him or her.

3. Even if you’re not cribbing actual lines or just vague ideas from your old stuff, just having your old stuff in your possession could raise suspicions that you might be using it for something. Imagine that Old Employer sues New Employer, and as one of a small handful of employees that moved from Old to New, you suddenly find yourself giving a deposition. None of you actually copied Old’s code into New’s product, but the lawyer in front of you asks: “Mr. SuperFoo, do you now or have you at any time since leaving Old Employer had in your possession a copy of any code that you or anyone else wrote while working at Old Employer?”

5. You don’t need the code that you wrote last month, last year, or longer ago. You solved the problem once, and now you know how to solve the problem again. Or, you may know how not to solve the problem — your new implementation will be better because you have experience.

6. There are better ways. It’s hard to go back and learn anything useful by reading old code out of context. A diary or journal that describes what you learn, ideas that you have, etc. is far more useful later on.

Even if Old Employer knows that you’ve got their code and is OK with that, you still don’t want it! The only thing that can come of having it is a 3am phone call:

Hey there, SuperFoo? How are you doing? Listen, you’ve got a copy of our stuff, right? Look, we’ve got a problem with the system, and we’ve narrowed it down to a couple files that you wrote that our new guy just doesn’t understand. I know it’s late, but could you walk him through SuperDuper?

Let it go. You don’t need it.

Leave a Reply