Programming Without Exceptions

One of Ron Jeffries‘ many interesting ideas is that of exceptionless programming. In this thread from the XP yahoogroup, he and others go into more detail on this technique.

The principle is that since exceptions are essentially non-local gotos, it’s preferable to avoid using them as far as practially possible. If you can test for failure first, do that. If you can return a null object that satisifies the caller’s expectations, do so. If the caller passes in invalid parameters, write a test and correct the calling code or make your function handle the incorrect parameters. Use exceptions only when you cannot find out whether an operation will succeed without trying it. Using exceptions for flow control is especially evil.

About Ian Davis

British entrepreneur and CEO of Kasabi. Primary interests are open data, the semantic web and decentralization.
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

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 )

Connecting to %s