C]+ Coding Standards

by Herb Sutter and Andrei Alexandrescu

Published 25 October 2004

Consistent, high-quality coding standards improve software quality, reduce time-to-market, promote teamwork, eliminate time wasted on inconsequential matters, and simplify maintenance. Now, two of the world's most respected C++ experts distill the rich collective experience of the global C++ community into a set of coding standards that every developer and development team can understand and use as a basis for their own coding standards.

The authors cover virtually every facet of C++ programming: design and coding style, functions, operators, class design, inheritance, construction/destruction, copying, assignment, namespaces, modules, templates, genericity, exceptions, STL containers and algorithms, and more. Each standard is described concisely, with practical examples. From type definition to error handling, this book presents C++ best practices, including some that have only recently been identified and standardized-techniques you may not know even if you've used C++ for years. Along the way, you'll find answers to questions like

What's worth standardizing--and what isn't? What are the best ways to code for scalability?What are the elements of a rational error handling policy? How (and why) do you avoid unnecessary initialization, cyclic, and definitional dependencies?When (and how) should you use static and dynamic polymorphism together?How do you practice "safe" overriding?When should you provide a no-fail swap? Why and how should you prevent exceptions from propagating across module boundaries?Why shouldn't you write namespace declarations or directives in a header file?Why should you use STL vector and string instead of arrays?How do you choose the right STL search or sort algorithm?What rules should you follow to ensure type-safe code?

Whether you're working alone or with others, C++ Coding Standards will help you write cleaner code--and write it faster, with fewer hassles and less frustration.




Modern C++ Design

by Andrei Alexandrescu

Published 13 February 2001

In Modern C++ Design, Andrei Alexandrescu opens new vistas for C++ programmers. Displaying extraordinary creativity and programming virtuosity, Alexandrescu offers a cutting-edge approach to design that unites design patterns, generic programming, and C++, enabling programmers to achieve expressive, flexible, and highly reusable code.

 

This book introduces the concept of generic components—reusable design templates that produce boilerplate code for compiler consumption—all within C++. Generic components enable an easier and more seamless transition from design to application code, generate code that better expresses the original design intention, and support the reuse of design structures with minimal recoding.

 

The author describes the specific C++ techniques and features that are used in building generic components and goes on to implement industrial strength generic components for real-world applications. Recurring issues that C++ developers face in their day-to-day activity are discussed in depth and implemented in a generic way. These include:

  • Policy-based design for flexibility
  • Partial template specialization
  • Typelists—powerful type manipulation structures
  • Patterns such as Visitor, Singleton, Command, and Factories
  • Multi-method engines

For each generic component, the book presents the fundamental problems and design options, and finally implements a generic solution.

 


Exceptional C++

by Herb Sutter

Published 10 December 1999
Exceptional C++ shows by example how to go about sound software engineering in standard C++. Do you enjoy solving thorny C++ problems and puzzles? Do you relish writing robust and extensible code? Then take a few minutes and challenge yourself with some tough C++ design and programming problems. The puzzles and problems in Exceptional C++ not only entertain, they will help you hone your skills to become the sharpest C++ programmer you can be. Many of these problems are culled from the famous Guru of the Week feature of the Internet newsgroup comp.lang.c++.moderated, expanded and updated to conform to the official ISO/ANSI C++ Standard. Each problem is rated according to difficulty and is designed to illustrate subtle programming mistakes or design considerations. After you've had a chance to attempt a solution yourself, the book then dissects the code, illustrates what went wrong, and shows how the problem can be fixed.Covering a broad range of C++ topics, the problems and solutions address critical issues such as: *Generic programming and how to write reusable templates *Exception safety issues and techniques *Robust class design and inheritance *Compiler firewalls and the Pimpl Idiom *Name lookup, namespaces, and the Interface Principle *Memory management issues and techniques *Traps, pitfalls, and anti-idioms *Optimization Try your skills against the C++ masters and come away with the insight and experience to create more efficient, effective, robust, and portable C++ code.
0201615622B04062001