Never remove a tool from your tool-box!!

Based upon Joel's recent post on the evils of Exception handling, I guess I have been foolish to worry so much about defining best practices in Exception Handling...

Of course, if Joel is correct, then it's equally an indictment of Microsoft, the .NET Framework, C#, Java, C++, and most other modern programming environments.  Not to mention the many fellow programmers who have generally posted their disagreement to Joel's controversial position!  :) 

I am still weighing my thoughts on this topic, but can definitely say that I believe in Exception Handling.  However, having said that, I also agree with the implication that Exceptions have largely been abused by many C++, Java, and C# programmers.  There ARE many cases where a return-value makes more sense, just as there are many cases where Exceptions make sense.  It is all about choosing the right tool for the job.

If you are a carpenter, who says “I don't like screwdrivers“ and use a hammer instead, your abuse of the tool will often end up making a mess of your projects.  As a programmer, I would expect the same....so my philosophy is to always choose the right tool for the job, and never take away a tool that you just might need one day!

 

2 Comments

  • I've worked with wood quite a lot in my time and I've found the best way is to hammer the screw most of the way in, then use the screwdriver on just the last bit.



    Same with exceptions. They can be a useful tool when you absolutely need them, but the more you have the more chance of accidentally exposing the user to one. Just try running sharpdevelop for a few minutes.. you will soon grow to hate them.



    Writing "exception safe" code is one of the most difficult parts of C++, just look at some of the articles on the subject. It might be easier in C# though, I haven't made my mind up yet.

  • Yep, the combination of Exceptions with Return values or Output params is definitely not mutually exclusive.



    I think you hit the nail on the head when you implied that Exception handling technique may be a language-specific decision.



    Having said that, I do believe that you will find some common patterns and shared best practices after enough research.



    My research continues...

Comments have been disabled for this content.