Sometimes, the best defense is a good offense. Other times, the best offense is a good defense. And if you’re not sure which is which, you’ll never be a true strategic mastermind.

Tina’s co-worker understands that this is true for defensive programming. Always, always, always catch exceptions. That’s a good defense.

Project getProject() {
    Project projectToReturn = null;
    try {
      projectToReturn = new Project();
    } catch (Exception e) {
      Logger.log("could not instantiate Project")
    }
    return projectToReturn;
}

The good offense is not actually doing anything useful with the exception and returning a null. Now the calling code needs to also go on the defense to make sure that they handle that null appropriately.

[Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. Get started with Otter today!