Rainy Day Code

Some programmers seem to be saving up carefully crafted functions and classes for a rainy day. There is no other reason for this code to exist. It was never used in the past. It has no immediate utility.

This is what makes it different from plain old dead code. For code to be dead it had to be alive at some point.

Examples include:

The last one is tricky, because there are lots of places where you should be careful. I'm talking about a special kind of case handling here, where the API documentation specifies that it will never happen, but the case to handle it is there just in case.

Also, I've seen elaborate catch blocks where operations like assignment or returning are wrapped in try blocks. The catch will absolutely never execute.

Really, can you imagine what would need to happen for:

  int x = 4;
to throw an exception?


EditText of this page (last edited January 17, 2008) or FindPage with title or text search