REVIEW - C++ Gotchas - Avoiding Common Problems in Coding and Design


C++ Gotchas

Avoiding Common Problems in Coding and Design


Stephen C. Dewhurst



Addison-Wesley Professional (2003)




John Mullins


February 2004



pretty much everybody can learn something from it.

Steve Dewhurst was one of C++'s earliest users and has been a trainer and consultant for many years. This book represents a collection of problems and their solutions that he has encountered in that time. The book is divided into nine chapters starting with Basics and moving through such things as syntax, resource management and the preprocessor through to class and hierarchy design.

Some of the Gotchas are not unique to C++ (e.g. Gotcha #3 - Global Variables), but crop up often enough to warrant inclusion. Much of what Dewhurst says cannot really be argued against but there are also items that many would consider controversial (for instance, Gotcha #18 discusses just where you should place const). There are also occasional items that look out of place; certainly Gotcha #12 (Adolescent Behaviour) doesn't seem to belong in a book about C++.

Much of this book is about communication, about what source code says to its reader (this to some extent probably explains the inclusion of Gotcha #9 - Using Bad Language). Dewhurst is forever emphasizing that source code should be written for the reader and not the compiler, as it will probably be maintained and updated many times. Much is made of idiomatic use of the language, use of the common form of expressions help to clearly express the intent of the author. The same can be said of the use of the standard library. Dewhurst also touches on design patterns, explaining how their use helps to document tried and trusted techniques. Other than a brief description of the mechanics of a particular pattern though, the author leaves detailed discussion to more specialized texts.

The book is aimed at neither experts nor beginners but at working C++ programmers, pretty much everybody can learn something from it. Of course this is not the first book of its kind and having a full collection of Scott Meyers' books on my bookshelf I was a little concerned there may have been very little new here, however I was pleasantly surprised to find only about 20% of the items overlapped and besides the approach of the two authors is very different. While having misgivings about one or two items this has been a welcome addition to my library, Recommended.

Book cover image courtesy of Open Library.

Your Privacy

By clicking "Accept All Cookies" you agree ACCU can store cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

By clicking "Share IP Address" you agree ACCU can forward your IP address to third-party sites to enhance the information presented on the site, and that these sites may store cookies on your device.