Home > Programming > ‘finally’ pitfalls

‘finally’ pitfalls

The ‘finally’ clause is very helpful to do clean up operations when working with costly resources, database connections etc. Even when an exception occurs, the finally clause is guarenteed to be executed thus ensuring that there are no resource leaks.

The pitfall is that its quite easy to end up writing some functionality code in the finally clause thinking that it would be executed after certain tasks. For example you might put your report writing code in a finally clause. So in case an exception occurs, the functionality code is also executed resulting in even more bugs!!

Categories: Programming
  1. No comments yet.
  1. No trackbacks yet.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: