Monday, 5 January 2009

Exceptions and the Lazy Programmer

Let's have a word on exceptions......

In other languages (no to mention Java), people are using Exceptions as way of doing error handling.
Now in Objective-C this surely not a good idea.
Because first of all its a very expensive mechanism in terms of CPU and memory stack (you should read the Apple documentation on it).
And secondly because it makes code difficult to read and to debug (try once to debug a program which is full of try/catch).

In my opinion Exceptions should only be used when things go really wrong and you need to stop (f.e: out of memory, disk crash etc).

I also developped a small Exception framework which I use in my daily coding. I'll publish it here (I'm gone try to use google docs to get things shared)


No comments:

Post a Comment