I was in a situation this week, where I have been fixing bugs in one particular part of our system for total of two weeks. This situation was created by too many reasons to really list (or perhaps warrants its own separate entry) and is a relatively unusual circumstance for our project since a maximum of two days is all we tend to need for each iteration. Being immersed in ‘maintenance mode’ for so long has really highlighted the different set of skills you tend to draw upon in contrast to our normal operating mode. It has also brought to my attention a few issues that can really help or hinder you when working in this mode. Here’s a few of them:
- Good logging statements (being careful not to damage the readability of code) that detail the complex state of a system in a readable is definitely helpful as you don’t need to add them yourself or to your debugger.
- Fast unit tests help to give early feedback when making changes to the system and a change breaks its contract with other components.
- Fast integration tests gives you the confidence that your system will continue to operate as it has in your production environment.
- Identifying a bug in business requirements before code is written is definitely cheaper than fixing it later on.
- Poor exception handling can mask the original source of error. For example, on a previous project, I remember the overly complex exception handling architecture triggered a
NullPointerException
when handling a simple business exception. - Code smells tend to become even more offensive as you wade through its source, which at least helps to identify areas that are good candidates for heavy refactoring or redesign).
- Repeatable test scenarios for a reported bug which are then translated into code are important against protecting against regressions.
- Though I agree with the whole philosophy of self-documenting code, I still find comments are important. I find the best ones tend to explain why a block of code was written in a particular way instead of another or the potential side effects changing that may have.