Sunday, September 8, 2013

Better be safe than sorry

Taking shortcuts is quite tempting when working on a project. A small bug fix may be seen as easy to apply, easy to deploy. That's where you're just raising the risk of introducing a catastrophic bug in your project.

You may have the skills, you may have the knowledge and the experience. But on a large project, it's almost impossible to know everything by heart. The interactions between components and classes are often complex and intertwined to a level that simply changing the logic flow of the GUI may alter the logic data flow. This can result in uninitialized objects, out-of-bound arrays or dead-locked threads. This is why any code modification needs to follow some simple golden rules to avoid having to execute a rollback...

Any project needs to be managed to reduce the level of risks of introducing new bugs. This is done by following some easy rules:

- The code will compile with the latest version of the whole project's source code
- The modification is working on your workstation
- Validate any conditions, extreme values, invalid data
- Check that your are handling exceptions and errors properly
- Double-check on a few other workstations. It may work only on yours...
- Add comments when required, update the documentation, write a test plan
- Run the unit tests!
- Update the unit tests if you changed the data flow
- Have a colleague review your code on complex modifications
- Execute a complete user scenario to ensure that what was working, still is...
- On committing your code, comment what was done and why, with bug number references, documentation and a small explicit text
- Make sure that is something goes wrong, your modification can be rolled back easily.
- When closing the bug as fixed, reference the revision number that your code was committed

It may looks as a longer process for a small bug fix. It's not! A 15 minutes bug fix may end up in hours of investigation and debugging time. Worse, your customers may lose production time which means loosing money because you wanted to meet your deadlines.

Time is money and we all know that money talks... Better be safe than sorry!

Patrick Balleux