Are you “Exception-safe”?

Life throws exceptions at us all the time
– the driver that suddenly cuts in front of you, angry client calls, curve balls thrown by family members and not to mention the crimes in the community, catastrophes around the world and so on.

Exception handling in coding is basically handling abnormal scenarios gracefully even though we don’t like for them to happen. Bad handling or no handling includes yelling at the user by showing them the internal error messages, blaming the user for the problem and/or crashing the application.

We all know why not having exception safe code is bad. It is simply asking for trouble as it is denial of the reality. Things happen. The best approach is to do as much as possible to prevent it but accommodate the rare occurrences of the odd ball cases that you are not aware of. The truth is you cannot anticipate everything.

Exception handling routines acknowledge the problem, log them for analysis later and help the program resume or quit in a reasonable fashion.

Just as it is good for your application, having such routines for your life also can be very beneficial for the same reasons.

So do you have exception handling routines for your life?

How would a template of such routine look like?

1. Catch the exception

It sounds trivial, but a lot of times we resist, deny, react angrily, get frustrated, blame others and so on when faced with “exceptional” people, situations and events.

Accept the exception that has been thrown. Understand that the present moment is the reality and it is inevitable.

90% of the problem is solved right here.

2. Handle the exception

Contemplate on the exception based on what information you have with an open mind.

If you do not want it to happen again, see what you can do about it.

Like, on your morning commute to work, you may want to give yourself additional buffer time so that when someone cuts in, you are ready because you are now relaxed and alert and most importantly not in a hurry.

Remember, the only thing you have control over is yourself just like the only thing you have control over in your application is your code and not what the user or machine or network does.

Change your attitude towards life.

Practice breathing and relaxation routines.

Eat healthy, Exercise, Drink plenty of water and

Dedicate some quiet time to yourself everyday.

Soon, you will find yourself handling the exceptions with ease and grace as they happen that they would merely become event handling.

Happy coding and stay exception-safe!

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: