[A picture of private offices at Fog Creek Software] Alert! This ancient trifle retrieved from the Joel on Software archive is well-past its expiration date. Proceed with care.

Joel on Software

15

by Joel Spolsky
Wednesday, October 15, 2003

DoSomething()

Ned Batchelder has written a spirited defense of exceptions.

With status returns:

STATUS DoSomething(int a, int b)
{
    STATUS st;
    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)
{
    DoThing1(a);
    DoThing2(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.


Have you been wondering about Distributed Version Control? It has been a huge productivity boon for us, so I wrote Hg Init, a Mercurial tutorial—check it out!

Want to know more?

You’re reading Joel on Software, stuffed with years and years of completely raving mad articles about software development, managing software teams, designing user interfaces, running successful software companies, and rubber duckies.



About the author.

I’m Joel Spolsky, co-founder of Trello and Fog Creek Software, and CEO of Stack Exchange. More about me.

© 2000-2014 Joel Spolsky