O'Reilly logo

Continuous Enterprise Development in Java by Aslak Knutsen, Andrew Lee Rubinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Continuity

“If everyone is moving forward together, then success takes care of itself.” - Henry Ford

The Zen of Prevention

At times it may feel that the universe mischievously conspires to destroy our work. And to some extent this is true: nature doesn’t like order. This entropy manifests itself in many ways; we open a network socket, a router may fail. We write to a file, the disk could fill up. We fail to check for valid inputs, our program could blow up unexpectedly.

Causes of potential failure are both infinite and inevitable. As guardians of our own code quality, we’re armed with two battle tactics: Be reactive, or be proactive.

Reactive Error Handling

Colloquially referred to as “firefighting”, a reactive position calls us to action. In most cases, an undesirable situation has already presented itself, and now we’re charged with fixing:

  1. The initial cause of the error, if under our control
  2. The unprotected areas of code which allowed the cause to wreck greater havoc
  3. Any resultant artifacts which persist after the error is encountered

Anyone who’s rifled through a database’s binary log file to restore data to a consistent state can attest to the stressful waste of time incurred in handling emergency situations after a breach in expected execution. Dealing with issues as they arise also imposes a sense of immediacy; the activities of a normal workday may be suspended to address more pressing concerns.

Clearly, the reactive model is not our best option if it can be avoided. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required