Step 28: Don’t Nail Your Program into the Upright Position ~Verity Stob

Birat Rai
2 min readOct 29, 2017

This is the 28th Step towards gaining the Programming Enlightenment series. If you didn’t learn the 27th Step, read it.

What is Exception?

An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program’s instructions.

When to handle Exception?

Valid Java programming language code must honor the Catch or Specify Requirement. This means that code that might throw certain exceptions must be enclosed by either of the following:

Code that fails to honor the Catch or Specify Requirement will not compile.

Is handling Every Exception great?

Obviously we don’t want our application to catch at any point of time. So, we start adding Exception handling mechanism, which later turns into a library.

We don’t have any crashes now. But, the downside is that now magically the problems in our application seem to disappear. We no longer know the bugs dwelling down inside the rabbit hole of the Exception handling mechanism.

UI designers’ rule: NEVER LET THE USER SEE AN EXCEPTION REPORT, rather as though this settled the matter, what with it being in caps and everything. But, as a developer the least we can do it spit out logs for whatever exception occurred and try to remedy it.

TL;DR Handle Exceptions, but don’t use try-catch everywhere. If used, use it wisely.

Go to the series.

Go to 27th Step

Go to the 29th Step.

References:

--

--