software monocytes…

A white blood cell which can ingest dead or damaged cells (through phagocytosis) and provide immunological defences against many infectious organisms.

There seems to be a crying need in many software organizations to have a (at least) few designated people whose job includes being software monocytes. That is to say they go around looking for code that is no longer being used or has been rendered obsolete by the passage of time.

Examples

  1. Dead Code
    For example, ‘obviously’ dead code like this should be cleaned up by the ‘monocyte’.

    if ( retrieveValue() == null ) {
         int x = 1;
    }
    

    and reduced to

    
    retrieveValue();
    

    But can the retrieveValue() call itself be eliminated?
    It might not be worth it to a regular developer to trace back down through all the method calls to see all of the original code is truly dead, but someone should. Expensive calls to the database could end up being eliminated.

  2. Obsolete Code
    In Java 1.4, Boolean Boolean.valueOf(boolean b) was introduced. That means all home-grown utility methods that did the same thing should be eliminated. (Of course with Java 5’s autoboxing any explicit method call is unnecessary)
  3. Commented out code
    How many times have you seen code that has been preserved for posterity

    
    // This code commented out because of a bug
    // with exporting as soon as this is fixed put this back.
    // t.exportData(true);
    // t = null;
    

    How long has this been preserved? Many times it turns out that it has been there for years… waiting for that developer to come back and uncomment it. In the mean time, successive developers have faithfully preserved this code, not quite certain of who put the comment in but unwilling to ignore the large “Do not erase”. Time for the monocyte to come through and erase it!

    (Side rant: that mystery developer should have attached the date and their initials to the ‘comment-out’ comment.)

To those who say everyone should be ‘monocytes’ and it shouldn’t be anything special: I would agree that that is ideal. However in larger code bases with lots of legacy code that may not be practical.

This entry was posted in technical. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *