Review:More Effective C++
On a different note, if you are interested in reviewing, drop me a line. We need more reviews, and I even have some books to send out as tank oos.
More Effective C++: 35 New Ways to Improve Your Programs and Designs | |
author | Scott Meyers |
pages | |
publisher | Addison-Wesley |
rating | 8/10 |
reviewer | SEGV |
ISBN | 0-201-63371-X |
summary | A fitting follow-up to a practical classic. |
More Effective C++: 35 New Ways to Improve Your Programs and Designs,
by Scott Meyers
[Addison-Wesley, ISBN 0-201-63371-X]
|
Episode VI: Return of the Guru
Scott Meyers has penned a worthy sequel to his original classic (now in its second edition, reviewed here). More Effecive C++ [online site] continues with the same style and quality, allowing the aspiring C++ student to further her skills with this powerful language.
Scope
This book pretty much assumes that you're familiar with the foundation laid in its predecessor. Because of that, it is able to skip the "basics" (like "use delete on pointer members") and get into more advanced topics.
Although it covers fewer Items, it is a larger book by quite a bit. Some Items are full (20+ pages) treatments of complex subjects, such as implementing smart pointers. Meyers takes you through all the nitty-gritty details of the topic at hand; by the time you're finished an Item, you not only know one or two Right Ways to do something, but also half a dozen Wrong Ways!
Content
After a brief treatment of a few more "basic" Items, Meyers leaps into a discussion of operators. Here he covers some points not present in the first book.
If you are using exceptions at all, the next Items will go far towards justifying the cost of this book. We hear about thread-safety, but often forget about exception-safety. Typically, the latter causes resource leaks, which are not as visible as the crashes caused by the former. Meyers not only explains the finer details of using exceptions properly, he also demonstrates idioms to make cleaning up after your code's mess easy and automatic.
Next Meyers discusses ways to help your code perform better and faster. Some are specific, lower level techniques, such as organizing your functions to facilitate the return value optimization. Others are generic, higher level techniques such as lazy evaluation, but it's valuable to see them illustrated in C++. All give you a deeper understanding of how C++ goes about its business.
The next Items are a set of techniques that you can apply in C++. These idioms may help you solve particular problems: for example, making functions virtual with respect to more than one object is how the Visitor pattern is implemented in C++. Even if you use existing code, such as auto_ptr
, it's enlightening and instructive to see exactly what's going on under the hood, as with smart pointers.
Finally, Meyers wraps up his treatise with some more general Items. I particularly like his idea of programming in the future tense. What he really means, is write code as it should be, not just as the compiler allows. If your design calls for constraints, enforce them in the code. Don't break encapsulation just for convenience. Build in flexibility. And so on.
Summary
I recommend this book. It's not as reference-worthy as its predecessor, but it has its own place on your bookshelf. It bears reading even if you borrow a copy.
Buy this book over this way.
TABLE OF CONTENTS
Acknowledgements
Introduction
Basics
Item 1: Distinguish between pointers and references
Item 2: Prefer C++-style casts
Item 3: Never treat arrays polymorphically
Item 4: Avoid gratuitous default constructors
Operators
Item 5: Be wary of user-defined conversion functions
Item 6: Distinguish between prefix and postfix forms of increment and decrement operators
Item 7: Never overload &&
, ||
, or ,
Item 8: Understand the different meanings of new
and delete
Exceptions
Item 9: Use destructors to prevent resource leaks
Item 10: Prevent resource leaks in constructors
Item 11: Prevent exceptions from leaving destructors
Item 12: Understand how throwing an exception differs from passing a parameter or calling a virtual function
Item 13: Catch exceptions by reference
Item 14: Use exception specifications judiciously
Item 15: Understand the costs of exception handling
Efficiency
Item 16: Remember the 80-20 rule
Item 17: Consider using lazy evaluation
Item 18: Amortize the cost of expected computations
Item 19: Understand the origin of temporary objects
Item 20: Facilitate the return value optimization
Item 21: Overload to avoid implicit type conversions
Item 22: Consider using op= instead of stand-alone op
Item 23: Consider alternative libraries
Item 24: Understand the costs of virtual functions, multiple inheritance, virtual base classes, and RTTI
Techniques
Item 25: Virtualizing constructors and non-member functions
Item 26: Limiting the number of objects of a class
Item 27: Requiring or prohibiting heap-based objects
Item 28: Smart pointers
Item 29: Reference counting
Item 30: Proxy classes
Item 31: Making functions virtual with respect to more than one object
Miscellany
Item 32: Program in the future tense
Item 33: Make non-leaf classes abstract
Item 34: Understand how to combine C++ and C in the same program
Item 35: Familiarize yourself with the language standard
Recommended Reading
An auto_ptr
Implementation
General Index
Index of Example Classes, Functions, and Templates
Review:More Effective C++ More Login
Review:More Effective C++
Related Links Top of the: day, week, month.
Slashdot Top Deals