Use exceptions rather than return codes

By Adrian Smith20 Apr 2007300 words2 mins to read

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 was written by Adrian Smith on 20 Apr 2007

Follow me: Facebook | Twitter | Email

More on: Coding | Language Design | Software Architecture