Ned Batchelder has written a spirited defense of exceptions.

With status returns:

STATUS DoSomething(int a, int b)
st = DoThing1(a);
if (st != SGOOD) return st;
st = DoThing2(b);
if (st != SGOOD) return st;
return SGOOD;

And then with exceptions:

void DoSomething(int a, int b)

Ned, for the sake of argument, could you do me a huge favor, let’s use a real example. Change the name of DoSomething() to InstallSoftware(), rename DoThing1() to CopyFiles() and DoThing2() to MakeRegistryEntries().

OK – Cancel

OK-Cancel Comic StripKevin Cheng: “There are four major classes of problematic programmers that I have worked with…”

And Back To Exceptions

There’s no perfect way to write code to handle errors. Arguments about whether exception handling is “good” or “bad” quickly devolve into disjointed pros and cons which never balance each other out, the hallmark of a religious debate. There are lots of good reasons to use exceptions, and lots of good reasons not to. All design is about tradeoffs. There is no perfect design and there is certainly never any perfect code.

Announcing the Joel on Software Book Club

Small Things Considered book cover imageThe imperfection of design is the theme of October’s Book of the Month. Did you ever think about why calculators have 1, 2, and 3 on the bottom row while phones put those keys on the top row? Why did the high beam headlight switch migrate from a floorboard pedal to a toggle on the steering shaft? Whatever you’re designing, from the error handling facilities of your software to the fat handle of a toothbrush which is highly ergonomic but can’t fit in anyone’s toothbrush holder, you have to trade off things that can’t really be balanced against each other. And no matter what you do, you’ll be subject to criticism, much of it valid.

Henry Petroski, who can write a 448 page book about the common pencil and make it fascinating, has done it again, this time with an excellent book about why there is no perfect design. All design is about tradeoffs, and if you don’t believe me, this book offers dozens of examples from everyday life. It even offers a candidate for the best designed object on the planet (the three-legged plastic nubbin that keeps your pizza box lid from sticking to the cheese) and shows why even that is imperfect. Small Things Considered: Why There Is No Perfect Design is another great read and it’s the first Joel on Software book of the month.

About the author.

In 2000 I co-founded Fog Creek Software, where we created lots of cool things like the FogBugz bug tracker, Trello, and Glitch. I also worked with Jeff Atwood to create Stack Overflow and served as CEO of Stack Overflow from 2010-2019. Today I serve as the chairman of the board for Stack Overflow, Glitch, and HASH.