Coding standards in this course must be observed, because many older compilers do not understand some of the latest ANSI C++ additions to the language.
Hence, the code in this course is specifically written to compile on both new and old compilers.
For this reason, we will continue to use the
.h suffix for libraries named in
In addition, we will not use namespaces, since only the most recent compilers support them.
The programmer or developer should implement coding standards that allow for the implementation of object oriented concepts as defined in C++.
Furthermore, the coding standards will allow a developer to read his own code several years from now as well as allow other developers to follow his programming thoughts.
Consistent, high-quality coding standards improve software quality, reduce time-to-market, promote teamwork, and simplify maintenance.
A set of coding standards that every developer and development team can understand and use as a basis for their own coding standards is discussed in this course. 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 are working alone or with others, Designing Reusable Code will help you write cleaner code--and write it faster, with fewer hassles and less frustration.