views:

1345

answers:

23

If so, how do you organize it? Do you refer to it often? Are there ethical implications?

I have a bunch of tarballs lying around that I keep telling myself I'll organize some day, but I've yet to get around to it. And when I do sneak peaks at it, I find that it's mostly obsolete and not applicable to current technologies anyway.

But I can't bring myself to throw it away!!! :-)

UPDATE I'm not referring to stealing code here, and I would never intentionally break a law by transferring IP between companies. The tarballs that I mention were obtained while gainfully employed, usually to facilitate working from home. At present, I have code I wrote from 5 previous jobs, and 3 of those companies don't even exist anymore. Since I'm a web developer, there's very little proprietary code anyway. Mostly CRUD apps with sometimes clever UI or performance hacks, but nothing that wouldn't be considered state-of-the-art and used across the web. So my question is basically, how do you preserve/evolve that state-of-the-art on an individual basis? Thanks to those of you who already answered the question in that spirit, and my apologies for not being completely clear initially.

+2  A: 

Online e.g. Box with a private view in folders.

I don't keep everything - just the stuff I think I'll reuse - not the complete source - just some classes etc..

And yes, I refer to it often.

I find the techniques rarely become obsolete - only the language they are written in.

nzpcmad
Now thats OO at its best!
Lucas McCoy
+31  A: 

Nope. I consider it the intellectual property of that company.

mezoid
That's right! :)
Maxim
Yes. In the vast majority of cases this is true. Unless you have a specific written agreement (as a contractor) for example, that says the code you write is yours, it almost certainly belongs to the company.
DasBoot
Code is not IP. Algorithms and Logic are IP. Code is copywrite, just like with books, and snippets without specific logic, say patterns and boilerplate fall within fair-use.
Robert Gould
Uhm... copyright is a type of intellectual property.
chaos
@Robert. Good point. If you just copy a few snippets that should be OK. But, if you copy a tar ball of the source then I believe that would get you into serious trouble. Intel sued one of its former employees for doing taking source code with him when he quit his job.
DasBoot
@Robert: Actually it's worse. The guys was actually arrested by the FBI. Here's a link: http://www.eweek.com/c/a/Desktops-and-Notebooks/Feds-Charge-ExIntel-Employee-with-Taking-1-Billion-in-Trade-Secrets/
DasBoot
Indeed, stealing the entire source is piracy, like pirating a movie or book, or anything like that. Although personal-use copying of copyrighted material YOU own is fine, such as source control, etc... stealing a movie will also theoretically get you caught by the FBI :)
Robert Gould
Copyright and IP are covered by different laws. Anything produced is automatically copyrighted, while other forms of IP requires extra effort and lawyers to be involved.
Robert Gould
From a legal POV IP is split into four parts: copyright, patents, trademarks and trade secrets. They are all IP.Taking code could be considered as stealing trade secrets, as per the IBM case. This is not the same thing as copyright violation.
mancaus
Good summary of IP mancaus!
Chris Ballance
Maybe it is their IP and maybe it isn't. Only your local IP lawyer knows for sure.
David Thornley
+3  A: 

According Charles Moore's guiding principles you don't need to keep all this code.
So - don't do this, as a good programmer , you always can write it again with more clever code.

Avram
Thats a waste of time unless you wrote something with lost of bugs in it.
Lucas McCoy
@Lucas, you can always improve, just start to try :-D
Avram
Reminds me of Charles Moore and his 'write your own subroutines' approach when reimplementing Forth - http://www.codinghorror.com/blog/archives/000190.html
Martin McNulty
@martinm thanks for the link :)
Avram
But Moore also brought his own card deck with Forth on it from job to job. (This was back in the punched-card days.) Sure he rewrote it over time, but that seems less relevant to this question.
Darius Bacon
@Darius, still its cost less if you write more relevant code, then trying to implement your old code in other places.And yes its maybe irrelevant answer for website,maybe but it relevant answer why the old code , must be just old code.
Avram
+4  A: 

I do not keep the code (for legal reasons) but it happened few times that I had a "similar" problem to solve and I was obviously using the experience from the previous job - without actually referring to the old code though!

Bogdan
+6  A: 

There is a post about the legal issues of this. I really liked it. Personally I feel so long as you don't break any laws and it can save you time then it's great and one of the best features of an OO language.

Lucas McCoy
A: 

Most of the time code you wrote for a commercial application is a tiny piece of the puzzle. So copying the source files you have contributed to do not make sense when seen by themselves, especially after a few months.

I have now taken to copying (and sometimes blogging) reusable snippets of code, something that can almost stand by itself for future references. I keep OneNote open on my machine for this purpose, so I can add comments along with the code. The snippets come in handy even in the same job.

Mohit Chakraborty
+2  A: 

Well the biggest hurdle are the legal ones - who owns the code? You or former employers (depends how much you signed away).

I guess the unofficial practice is common - in which case the code isn't shared.

For things I have been allowed to keep, I simply keep it all somewhere a text indexer can reach. Most of it really isn't that useful I find, as you learn over time. Its only for looking up tricks for a particular API you once used.

Michael Neale
+1 for recognizing that there is a legitimate legal question with a non-obvious answer.
David Thornley
A: 

Nothing inherently wrong with keeping things for your own reference, just don't get yourself sued by reusing it for another employer or selling it.

The code itself from a previous job doesn't necessarily have much value outside of that job, but what you have learned while there, is often much more valuable to have than some code you wrote while there.

Chris Ballance
+2  A: 

I don't save the code.

However, if I find a bit of information that might be interesting to the rest of the community, I blog about it. I make sure not to leave any proprietary code or anything that might indicate where it comes from.

Normally, the code itself is not interesting. It's how you solved the problem that is interesting and that alone... is worth blogging about.

The kind of stuff that might be interesting to blog about is when you understand a part of the framework that you might have problem to remember again.

Maxim
A: 

In my case, I was allowed to keep sections of code for my portfolio. As far as ethics goes, it all boils down to the agreement between you and your former employer.

Now, as I look back at the code I had, I have the same reaction you do. Either it needs some serious rewrite, or is just so obsolete it can't be saved.

I would assume that it's safe to get rid of your old work unless there were a reason to keep that particular code around, like the portfolio. However, if it really comes down to it, couldn't you do something better with the knowledge that you've gained since then?

Coronus
+1  A: 

The smartest thing that I've seen done is one programmer that convinced management to allow him to write the code on his own time using ideas from a previous job. They then paid him for the rights to use the framework. This was for a C++ ORM back before they were 'cool.'

He then was able to keep the rights to the code, and allowed them permission to use it.

While I've kept copies of the code I've written on disk (or floppy, if anyone remembers those) I've only refered to them once when i was contacted for a Y2K udpate, and have never used them in another job, and I doubt that I ever would because of legal concerns.

Ralph
+1  A: 

There are two question that discuss this topic that you may want to check out.

As to the If so, how do you organize it?

As to the Are there ethical implications?

lillq
He didn't ask if it was ethical; just how do you do it.
Jeff O
@Guiness His first line asks 3 questions. One of which is "Are there ethical implications?"
lillq
A: 

The best thing you can probably do is to save those nuggests of code that are helpful to someplace that is a code repository so that others can benefit from your work as well. planetsourcecode is one such place. In the pre-internet days, I kept a toolbox for code that mattered, but now Visual Studio will organize those things for you.

I am not too sure that you're bending any ethical rules so long as the what you're saving is rather atomic.

James Fleming
+4  A: 

Yes, I save my code from previous contracts. When I have to solve a problem I know I've solved before I look at my old code.

For example: "How did I use Reflection to get all the Properties of a class?." I could Goggle but since I know I did something like this (to serialize a class) in a previous project, I just look in that old project. I get the "Oh yeah, that's how I did it." and then continue coding. I will not under any circumstances copy and paste any of my old code if it belongs to a another client.

Chris Bennet
+1  A: 

Depends on the company. I still have some code I wrote at a previous job because it was directly related to my (still running) Ph.D when i resigned. Of course, the Ph.D was sponsored by the company and the code was theirs but it would have been impossible to carry on without it because it was the result of a couple of years of research and investigation.

Adam Hawes
A: 

What a great question! Source code can be copyrighted, but can it be protected under a patent? As 'instructions', which are not patentable, it cannot, but the patent office is looking into this issue.

jle
A: 

I always keeps reusable code i wrote ,

Priyan R
+18  A: 

I do not save code I create for others, because it may infringe on copyright.

However, while programming I learn many things (techniques, API's, idioms, etc) which I save in a separate project consisting of example code. Every time I learn something new I either blog about it and/or create an example distinct from the code I write professionally.

This way I have reference material for myself without having to save proprietary code.

Parag
+1, I agree, using this method myself.
mizipzor
+1, Dido I do this too
gnucom
+1  A: 

I always keep code that is reusable or stuff I wrote off the clock on my own projects but have used in company projects..that I consider mine... but if I am bound by non disclosure or non compete then generally it stays with the company as it is theirs.

dswatik
How do you downvote this? "Do you save the code you wrote at your previous jobs?" is a subjective question, it's impossible for the dswatik to be "wrong".
annakata
Why would anyone be wrong? This isn't a pop quiz
dswatik
+1  A: 

I doubt if it is legal keeping the code even for reference. Especially if you created it at work, on the company's hardware, and to keep it you'd have to make unauthorized copy.

What I'm sure is, that you should never copy & paste that code into new project. That would be creating derived work based on copyrighted material, thus illegal.

vartec
+1  A: 

I write a lot of stuff on my own time which I'll then use for problems at my day job. Going to the next job I'll bring the stuff I wrote forward. That kind of muddies up what I'm doing I guess, because there's no way I'm giving away the rights, but it does work for the companies benefit.

Taking a tree is clearly wrong, but taking generic methods (there's only so many times a man can write an XML->JSON transform) just seems like efficiency. It's not like it's unique IP, and it's not like you wouldn't just write the same thing again if you had to solve the problem again.

annakata
A: 

I post samples of it on SO when answering questions :P

luvieere
+1  A: 

I used to. After a while I realized that I never looked at 99+% of it anyway. So I just saved snippets of the parts I wanted to remember and trashed the rest. There's no need to be a digital pack rat with the other hundreds of thousands of lines of code just in case you need a line or 2 one day. Save the useful bits and look up the rest later. Also, later someone will probably have improved upon the methods anyway.

Dinah