The joy of deleting code

What could be more fun than writing a new shiny super-functional, super-tested piece of code? Deleting it!
When deleting code you know that

  • You have not introduced new bugs. Perhaps you deleted some potential bugs from the old code but chances are you did not introduce new ones.
  • You don’t have to maintain it. It’s deleted.
  • Code was probably poorly written. Good code is never deleted. In many cases there’s poorly written code that you just don’t have the guts to delete it. Now you did, that’s great.
  • You’ve probably found a good way to reuse another piece of code, that’s why you’re deleting this piece of code. Code reuse is good.
  • Or that you’ve taken off a feature from your product. Taking off features is good, is very good. Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away
  • Or that you’ve found a more compact and elegant way to do what you want to do.

Bottom line: Deleting code makes me happy. How about you?


5 Responses to “The joy of deleting code”

  1. That’s so true. Getting rid of code is joyful. Especially, if you’re feeling that you’re loosing control over your code, deleting redundant parts is a key step towards sanity.

    A slight reservation. Deleting does not always imply that no bugs are introduced. Example: you delete code that eliminates duplicates from a list. Then you realize that somewhere else in your code you needed this list to have duplicates (because it needs to be synchronized with the a raw data or something). Thus, we should not take for granted the assumption that we cannot introduce bugs when we delete. I do agree, though, that when deleting code the chances of introducing bugs are quite slim.

    By Itay Maman on Oct 3, 2009

  2. LOL

    Normally when I refactoring old code I find myself deleting about half of the code while maintaining the same functionality.

    Has anyone noticed that it is usually a big pile of ugly static code that gets to be deleted?

    By Eran on Oct 24, 2009

  3. I’ll drink to that! :)

    By Yossale on Nov 22, 2009

  4. I’ll DELETE to that!

    By F. Aquino on Mar 23, 2010

  5. It’s true, however when deleting a code you must be 100% sure it is not needed. This usually the hardest part.

    By chen f on Apr 4, 2010

Sorry, comments for this entry are closed at this time.