Safe C++
How to avoid common mistakes
Publisher: O'Reilly Media
Final Release Date: May 2012
Pages: 142

It’s easy to make lots of programming mistakes in C++—in fact, any program over a few hundred lines is likely to contain bugs. With this book, you’ll learn about many common coding errors that C++ programmers produce, along with rules and strategies you can use to avoid them.

Author Vladimir Kushnir shows you how to use his Safe C++ library, based in part on programming practices developed by the C++ community. You’ll not only find recipes for identifying errors during your program’s compilation, runtime, and testing phases, you’ll learn a comprehensive approach for making your C++ code safe and bug-free.

  • Get recipes for handling ten different error types, including memory leaks and uninitialized variables
  • Discover problems C++ inherited from C, like pointer arithmetic
  • Insert temporary and permanent sanity checks to catch errors at runtime
  • Apply bug prevention techniques, such as using separate classes for each data type
  • Pursue a testing strategy to hunt and fix one bug at a time—before your code goes into production
Table of Contents
Product Details
About the Author
Colophon
Recommended for You
Customer Reviews

REVIEW SNAPSHOT®

by PowerReviews
oreillySafe C++
 
3.5

(based on 4 reviews)

Ratings Distribution

  • 5 Stars

     

    (2)

  • 4 Stars

     

    (0)

  • 3 Stars

     

    (1)

  • 2 Stars

     

    (0)

  • 1 Stars

     

    (1)

67%

of respondents would recommend this to a friend.

Pros

  • Accurate (3)
  • Easy to understand (3)
  • Helpful examples (3)

Cons

    Best Uses

    • Novice (3)
      • Reviewer Profile:
      • Developer (3)

    Reviewed by 4 customers

    Sort by

    Displaying reviews 1-4

    Back to top

    (5 of 6 customers found this review helpful)

     
    3.0

    I have mixed feelings here …

    By mko

    from Poland

    Verified Reviewer

    Pros

    • Concise
    • Helpful examples

    Cons

    • Not comprehensive enough
    • Too basic

    Best Uses

    • Novice
    • Student

    Comments about oreilly Safe C++:

    Safe C++ is quite interesting book, however, after reading it I have mixed feelings. At some point it is targeted at begineers. If you don't know how to avoid memory related mistakes, how to recover from the run-time errors, or how to hunt bugs you don't know much about safe coding yet. In that case this book is definitelly for you. On the other hand, it requires quite good knowledge in C++ related area. I think, that knowing C++ well triggers some knowledge regarding topics covered in the book as well. Anyway, there are few nice topics there, and let me discuss them briefly.

    Book itself is divided into three parts. First – describing what can be the source of issue, second – providing overview for some basic strategies that can save your time and effort, and third – telling you how to prepare the code for delivery. I think that last part is there just for the purpose of being there. It is short, condense and doesn't teach you how to make things right. First part tells some obvious things regarding issues you can encounter during development. If you are real begginer this will be a good source of the information for you. If you are experienced developer, feel free to skip it. Most interesting part of the book can be found in second part. Here you will find the essence of the book. You will go over the sections covering different types of issues and you will be told how to overcome them. Each section contains brief summary that makes it much easier to learn things.

    One thing that stroke me during the lecture was the strong assumption of the author that you will write self estime code from the scratch. Which is not quite a use-case in real life. Of course, following the rules proposed by Vladimir will definitelly help you develop better and safer applications, but sometimes this is not possible to develop in isolation. You will depend on external libraries, you will have to access external data sources, you will deal with the inherited code nobody remembers already. In these cases simple rules are not enough. What I would like to find in this book are the tools and methods for tracking the issues, memory leaks, code analysis etc. Let me explain by few examples. For example, Vladimir suggests using dedicated scpp::vector class instead of std::vector. This sounds fine, but he makes very strong assumption that you will never cast to std::vector even though you inherit from it. This is very strong assumption taking into account that most of the people use std::vector and you will have to cast sooner or later. Another example is to use smart pointers to track the allocations. But what about things allocated inside some legacy code? How to track memory leaks there? The same reffers to the section covering the code being easier to debug. The code might be better for debugging but definitelly not easier to read for developer. I know that you always have to make a tradeoff, but still, I think there are better ways to make debugger friendly code comparing to #ifdef DEBUG based inner fields of classes.

    Overlally, I think this book will be very interesting for beginners who have already learned C++ but they lack the real life experience. When it comes to experienced developers, I am pretty sure you know most of the solutions presented in the book already. Otherwise you wouldn't be able to survive in the industry.

    (0 of 2 customers found this review helpful)

     
    5.0

    Great Book

    By Dann Luciano

    from Natal, RN, Brazil

    About Me Developer, Educator

    Verified Reviewer

    Pros

    • Accurate
    • Concise
    • Easy to understand
    • Helpful examples
    • Well-written

    Cons

      Best Uses

      • Novice
      • Student

      Comments about oreilly Safe C++:

      Help me to solve the basics problems in the c++.
      Easy ans simples solutions.
      Use the recomendations and be happy.

      (10 of 10 customers found this review helpful)

       
      1.0

      Doesn't deliver what title promises

      By teak

      from Jyväskylä, Finland

      About Me Developer

      Verified Reviewer

      Pros

      • Accurate
      • Easy to understand
      • Helpful examples

      Cons

      • Incorrect title
      • Too basic

      Best Uses

      • Novice

      Comments about oreilly Safe C++:

      I got this book via O'Reilly Blogger Review Program.

      I didn't check the back cover when I started to read this 150 page short (previous book was Programming Perl with 1000+ pages) book. Almost immediately it started to feel like infomercial about a c++ library made by the author. Half way through I checked the back cover and found out that the book also shows how to use this library but the back cover also promised more wider look in how to make bug free code.

      I found very little of anything else than his Safe C++ library. There was some mentioning about testing, but nothing about unit-tests. Memory errors were talked a lot but no mentioning about Valgrind (or anything else) for hunting them, just saying use the library. In the end there was a chapter "Making Your Code Debugger-Friendly" which was basically the only place where debuggers were mentioned. About one quarter of the book was source code of the library. There was also a nothing on sanitizing the user inputs which goes under safety.

      If the title had been "Safe C++ library" or something similar I would have been a lot more lax in the review, but with current title I disliked the book.

      I wouldn't recommend the book to anybody. If you are newbie one needs to learn the standard tools and not some obscure library, if you are seasoned the stuff in the book is old news for you.

      I'd rate this 1/5, with more correct title 2.5/5.

      (1 of 1 customers found this review helpful)

       
      5.0

      Review of Safe C++ by Vladimir Kushnir

      By hfb

      from Nashua, NH

      About Me Developer, Engineer

      Verified Reviewer

      Pros

      • Accurate
      • Easy to understand

      Cons

        Best Uses

        • Intermediate

        Comments about oreilly Safe C++:

        I have been programming in Arduino a lot lately and keep running into a lot of problems as I compile the code. That's where Safe C++ comes in really handy.
        This is a good reference for anyone that's looking to become a better programmer by knowing what the basic pitfalls are. If you're learning to program, this probably isn't going to be for you but if you already know how to program and are learning a new language or brushing up on one, this works out well for C++.
        Ultimately for Safe C++, you really should know the language beforehand as it goes through some important things such as pointers. If you know what a pointer is an how to use it, then you should be able to use this book just fine.

        Disclaimer: This book was received as part of the O'Reilly Blogger Review Program. All comments represent my thoughts and opinions.

        Displaying reviews 1-4

        Back to top

         
        Buy 2 Get 1 Free Free Shipping Guarantee
        Buying Options
        Immediate Access - Go Digital what's this?
        Ebook: $21.99
        Formats:  DAISY, ePub, Mobi, PDF
        Print & Ebook: $27.49
        Print: $24.99