Deleting code gives me a warm fuzzy feeling…

I love it when I get to delete code. Deleting code, particularly dead code, is such a wonderfully therapeutic exercise. You should try it some time.


That’s why I love it when I find code like the method I just stumbled across. It cast the result of a Hibernate Session.find()[1] call directly to a domain object. But that would never work: instant class cast exception!

Quick scan of the code base: yep, this method never gets used anywhere. And 5 seconds later, this method no longer exists. And only the CVS system has any evidence it ever did…

—-

[1] sf.net.hibernate.Session.find(String) returns a java.util.List

Author: Robert Watkins

My name is Robert Watkins. I am a software developer and have been for over 20 years now. I currently work for people, but my opinions here are in no way endorsed by them (which is cool; their opinions aren’t endorsed by me either). My main professional interests are in Java development, using Agile methods, with a historical focus on building web based applications. I’m also a Mac-fan and love my iPhone, which I’m currently learning how to code for. I live and work in Brisbane, Australia, but I grew up in the Northern Territory, and still find Brisbane too cold (after 22 years here). I’m married, with two children and one cat. My politics are socialist in tendency, my religious affiliation is atheist (aka “none of the above”), my attitude is condescending and my moral standing is lying down.

3 thoughts on “Deleting code gives me a warm fuzzy feeling…”

  1. Robert – obviously in the example you had you where 100% confident you could delete it (as it would never work anyway).

    What about in cases <100%… to get the confident sleep-well-at-night feeling after deleting – how do you go about being sure it isn’t used?

    I guess test coverage would be a large part…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: