Tags

, ,

I recently read an article in the February 2011 edition of PragPub magazine called “Refactoring Your Job”.  The basic theme of the article was about finding meaning in your job during hard economic times.  The article has some interesting points but the sentence in the article that had the most meaning for me had nothing to do with the articles theme.

In the section titled “Slash and Burn” the author discusses code refactoring to remove dead, unreachable code and makes the following statement.

“Take the opportunity to heavily instrument code. In my case, I created a special logging level called DEPRECATE, then threw logging in suspect procedures.”

This idea jumped out at me as a potentially risk free way to cut out dead code.  While adding or refactoring, whenever you come across code that looks suspiciously unused, instrument it with this “Depricate” tag.  Then as the solution get tested, propagated and released, monitor this log to see if the code is used, and if so, how much.  This can give you some real world metrics and proof that code blocks are actually dead and can be removed or very seldom used and a candidate to for refactoring.

Just a thought …

Advertisements