Wednesday, July 4, 2012

Safe C++ - Book Review

Everybody knows how is tricky to manage all the complexity and the feature that c++ provides. From memory allocation to copy constructor ending up with address manipulation, It's very easy to make a mistake and sometimes is difficult to find the reason of it.

Safe C++ is a book for intermediate C++ users who wants avoid common mistakes that usually happens. From memory leaks to comparison operator, the book explains how a simple macro definition can help you to remove problems. The book is easy to read for who is practical with C++ and the 140  pages that composes it flows very fast. The book is composed by 17 short chapters, each of which tackles a specific issue:

The first 3 chapters are sort of introduction to the specific issues treated later in the book:
 Chapter 1: Where does c++ bugs come from?
 Chapter 2: When to catch a bug?
 Chapter 3: What to do when we encounter an error at runtime.

The middle chapters are more specific and tackles a specific issue:
 Chapter 4: Index out of bounds
 Chapter 5: Pointer Arithmetic
 Chapter 6: Invalid Pointers, References and Iterators
 Chapter 7: Uninitialized Variables
 Chapter 8: Memory Leaks
 Chapter 9: Deferencing NULL pointers
 Chapter 10: Copy Constructors and Assignment operators
 Chapter 11: Avoid writing code in the destructors
 Chapter 12: How to write consistent comparison operators
 Chapter 13: Errors when using Standard C libraries

The last three chapters talks about testing and how to help the debugging process:
 Chapter 14: General testing principles
 Chapter 15: Debug-On-Error strategy
 Chapter 16: Making your code debugger-friendly   

 This book explains how to avoid most common mistakes and bad pratices when programming in C/C++. It's a good book for intermidiate and can help also beginners to understand some tricky behaviour of C++. Together with other more general books as the pragmatic programmers series and so on, can be a good reading to master a good coding style.

No comments:

Post a Comment