- Shopping Bag ( 0 items )
From Barnes & NobleThe Barnes & Noble Review
To paraphrase the novelist Leo Tolstoy, every well-written program is the same -- but bad C++ code is all different. In C++ Gotchas, Stephen Dewhurst brings together 99 of the most common ways programmers write lousy code -- and provides practical solutions.
These “gotchas” run the gamut from beginner’s mistakes (like using hard-coded “magic numbers”) to subtle issues in class and hierarchy design. Dewhurst illuminates them with clear explanations of why they’re wrong and tells you what to do instead.
For example, in a detailed chapter on memory and resource management, he explains why you shouldn’t check whether a particular memory allocation has succeeded. (Instead, use new to throw a bad_alloc exception in the event of allocation failure. That lets you encapsulate error-handling code for allocation failure, for a cleaner, more efficient design). Later in the same chapter, he explains why you should believe your compiler when it objects to pointers or references returned to local variables; why it’s all too easy to misuse the standard auto_ptr template; and much more.
You’ll find gotchas related to C++ syntax; to the preprocessor; conversions; initialization; polymorphism; even programmer psychology. After you read this book, you’ll have to find entirely new mistakes to make. Bill Camarda
Bill Camarda is a consultant, writer, and web/multimedia content developer. His 15 books include Special Edition Using Word 2000 and Upgrading & Fixing Networks For Dummies®, Second Edition.