Skip to Main Content
Code Craft
book

Code Craft

by Pete Goodliffe
December 2006
Intermediate to advanced content levelIntermediate to advanced
610 pages
22h 58m
English
No Starch Press
Content preview from Code Craft

Raising Hell

We’ve put up with other people’s errors for long enough. It’s time to turn the tables and play the bad guy: Let’s raise some errors. When writing a function, erroneous things will happen that you’ll need to signal to your caller. Make sure you do—don’t silently swallow any failure. Even if you’re sure that the caller won’t know what to do in the face of the problem, it must remain informed. Don’t write code that lies and pretends to be doing something it’s not.

Which reporting mechanism should you use? It’s largely an architectural choice; obey the project conventions and the common language idioms. In languages with the facility, it is common to favor exceptions, but only use them if the rest of the project does. Java and C# really ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Write Great Code, Volume 2, 2nd Edition

Write Great Code, Volume 2, 2nd Edition

Randall Hyde
The Art of Clean Code

The Art of Clean Code

Christian Mayer

Publisher Resources

ISBN: 9781593271190Errata