Use exceptions rather than return codes

Exceptions have been around for a long time. There's no reason not to use them.

I don't want to ever see code such as this ever again.

if ( ! $user) return false;

We all know what happens with such code:

Every language in use today, at least in the projects I work on, has ways of handling exceptions.

One needs to simply be assertive, realize that exceptions are much better, and insist on using them.

Update: This article was written before the go language was released, which famously doesn't have exceptions. I think that's a big mistake on the part of the designers of the go language.

This article is © Adrian Smith.
It was originally published on 20 Apr 2007
More on: Coding | Language Design | Software Architecture