C++ Coding Standards: 101 Rules, Guidelines, & Best Practices

(häftad)

101 Rules, Guidelines, and Best Practices

av Herb Sutter, Andrei Alexandrescu

Bloggar      
Format:
Häftad (paperback)
Utgiven:
2004-11-01
Språk:
Engelska

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.



Passar bra ihop

C++ Coding Standards: 101 Rules, Guidelines, & Best Practices + More Exceptional C++
De som köpt den här boken har ofta också köpt More Exceptional C++ (häftad) av Herb Sutter
Pris för båda:
534:-Köp

Fler böcker av författarna

Visa alla böcker av Herb Sutter, Andrei Alexandrescu
The D Programming Language (häftad)
Modern C++ Design (häftad)
Concurrent Programming on Windows (häftad)
Exceptional C++ Style: 40 New Engineering Puzzles (häftad)

The D Programming Language

Andrei Alexandrescu (häftad)

Modern C++ Design

Andrei Alexandrescu (häftad)

Concurrent Programming on Windows

Joe Duffy, Herb Sutter (häftad)

Exceptional C++ Style: 40 New Engineering Puzzles

Herb Sutter (häftad)
290:- Köp
313:- Köp
313:- Köp
282:- Köp

Kundrecensioner

Bli först med att recensera och betygsätt boken C++ Coding Standards: 101 Rules, Guidelines, & Best Practices - du kan vinna 200 kr varje månad i tävlingen "Månadens recension".

Bloggat om C++ Coding Standards: 101 Rules, Guidelines, & Best ...

Övrig information

Herb Sutter is the author of three highly acclaimed books, Exceptional C++ Style, Exceptional C++, and More Exceptional C++ (Addison-Wesley). He chairs the ISO C++ standards committee, and is contributing editor and columnist for C/C++ Users Journal. As a software architect for Microsoft, Sutter leads the design of C++ language extensions for .NET programming. Andrei Alexandrescu is the author of the award-winning book Modern C++ Design (Addison-Wesley, 2001) and is a columnist for C/C++ Users Journal.

Innehållsförteckning

Preface.

1. Organizational and Policy Issues.

    Don't sweat the small stuff. (Or: Know what not to standardize.).

    Compile cleanly at high warning levels.

    Use an automated build system.

    Use a version control system.

    Invest in code reviews.

2. Design Style.

    Give one entity one cohesive responsibility.

    Correctness, simplicity, and clarity come first.

    Know when and how to code for scalability.

    Don't optimize prematurely.

    Don't pessimize prematurely.

    Minimize global and shared data.

    Hide information.

    Know when and how to code for concurrency.

    Ensure resources are owned by objects. Use explicit RAII and smart pointers.

3. Coding Style.

    Prefer compile- and link-time errors to run-time errors.

    Use const proactively.

    Avoid macros.

    Avoid magic numbers.

    Declare variables as locally as possible.

    Always initialize variables.

    Avoid long functions. Avoid deep nesting.

    Avoid initialization dependencies across compilation units.

    Minimize definitional dependencies. Avoid cyclic dependencies.

    Make header files self-sufficient.

    Always write internal #include guards. Never write external #include guards.

4. Functions and Operators.

    Take parameters appropriately by value, (smart) pointer, or reference.

    Preserve natural semantics for overloaded operators.

    Prefer the canonical forms of arithmetic and assignment operators.

    Prefer the canonical form of ++ and --. Prefer calling the prefix forms.

    Consider overloading to avoid implicit type conversions.

    Avoid overloading &&, ||, or , (comma).

    Don't write code that depends on the order of evaluation of functionarguments.

5. Class Design and Inheritance.

    Be clear what kind of class you're writing.

    Prefer minimal classes to monolithic classes.

    Prefer composition to inheritance.

    Avoid inheriting from classes that were not designed to be base classes.

    Prefer providing abstract interfaces.

    Public inheritance is substitutability.

    Inherit, not to reuse, but to be reused.

   ...

De som köpt "C++ Coding Standards: 101 Rules, Guidelines, & Best Practices" har även köpt:

Exceptional C++ (häftad)

Exceptional C++

Herb Sutter (häftad)
259:-
More Effective C++ (häftad)

More Effective C++

Scott Meyers (häftad)
290:-
Effective STL (häftad)

Effective STL

Scott Meyers (häftad)
282:-
API Design for C++ (häftad)

API Design for C++

Martin Reddy (häftad)
291:-
C++ Coding Standards: 101 Rules, Guidelines, & Best Practices (häftad)
  • Titel: C++ Coding Standards: 101 Rules, Guidelines, & Best Practices
  • ISBN: 9780321113580
  • Förlag: ADDISON-WESLEY
  • Utgivningsland: USA
  • Utgivningsort: Boston
  • Medarbetare: Alexandrescu, Andrei
  • Upplaga: 1
  • Antal sidor: 220
  • Vikt: 500 g
  • Höjd: 235 mm
  • Antal komponenter: 1
  • Format: Häftad (paperback)