Toss It

If something isn't being used or isn't useful, get it away from you. You don't need the distraction. This applies to code as well as other things.


If you've been good about following DoTheSimplestThingThatCouldPossiblyWork, you shouldn't have much dead code in your system, but if you do find dead code it is better to TossIt than save it for a rainy day. First of all, having it there complicates understanding of a system. Secondly, it leads to misunderstandings of the system's capabilities.

TossIt is especially important for projects that are trying to go extreme.

TossIt is how you maintain ExtremeNormalForm when you RefactorMercilessly.

You shouldn't have things around you because "you might, sort of, kind of, may need them later (and besides, it's already there)." No.

YouArentGonnaNeedIt. TossIt.


But won't my company lose its investment?

No. That is what version control tools are for.

And what company ever actually profited from old software they had lying around, anyway?

Never had to patch an old release? It's not all IllusionOfControl. Plus a good SCM tool will let you integrate by merging rather than locking - very needful in larger developments.


If it's not being used, delete it. Otherwise, you'll have to maintain it.

Yes, I've often found, in projects with dead code lying around, that we frequently find ourselves spending time maintaining and attempting to test code that is not used at all. It happens when you change function "X", and then go fix everything that calls X. You get confused with some of the code calling X, because you can't see how it could have worked before your change. Discovery: It didn't work! And no one noticed, because the code wasn't been used anyway. So DELETE IT! If you need it later, get it from the source control system. -- JeffGrigg


I once deleted (more precisely, donated) several hundred books, because I "wasn't using them." I have never regretted anything more. At least for BookAddicts, books can serve a purpose when they aren't being read. They can be a roadmap of your intellectual development. They can have sentimental value, such as books that you had when you were a kid, or books that greatly influenced you. You can find yourself browsing them and reviving old mental threads now that you have new material to go with them. Books tell houseguests what you like, what kind of person you are. You can lend or give them to friends. And they are a wonderful, understated form of decoration. "A room without books is like a body without a soul."

So here's a principle: if it's difficult to replace, don't toss it just yet, TentativeTossIt.

There's also another principle here, something about MuseumsArchivesLibraries?, something that balances (grossly overgeneralized) YouArentGonnaNeedIt. Some things are valuable to keep permanently even though they're obsolete. The trick is to hold on to the baby pictures and first working prototypes without becoming a packrat.

--BenKovitz


Luckily code is never difficult to replace (or to reaquire) if you're using any sort of versioning system, as stated above. Regarding code, you can always TossIt without any mercy. If you ever need it again, of if you want to have a glimpse on how your software evolved thru time, you just browse your VCS repository.

Just as reading the titles or the contents of your old books, browsing your old VCS repository can be good sometimes. You see today how you thought yesterday. You're able to reminde what kind of mistake you did on the old days, and remember why you don't do the same mistakes anymore. You're able to see the evolotion of your software and your mind. A well-set ViewCVS page is really nice to browse from time to time. Better yet if you like to include CommitLogJokes?.

--MarcusBrito

That's really great if you have version control and are very methodical about always recording every little test, utility, and code fragment you have ever committed to mass storage. Some of us work in a sloppier environment, so TentativeTossIt works better. Even more so when you need to record TheRoadNotTraveled.


I toss code with out any worries if I have a version control system like CVS and a good GUI client. I use EclipseIde which has an excellent GUI interface to CVS. I am little careful, if I do not have version control system. I do not remember a single instance where I had to go back to the code I tossed. -- GunjanDoshi
See: PerpetualNow

Contrast: TentativeTossIt, TheRoadNotTraveled


EditText of this page (last edited May 2, 2005)
FindPage by browsing or searching

This page mirrored in ExtremeProgrammingRoadmap as of April 29, 2006