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

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:

Gravatar
WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Connecting to %s