Scott Myers' Effective C++ Rules
From his book, ISBN 0-201-26364-9
- Use const and inline instead of #define.
- Prefer iostream.h to stdio.h.
- Use new and delete instead of malloc and free.
- Prefer C++ style comments.
- Use the same form in corresponding calls to new and delete.
- Call delete on pointer members in destructors.
- Check the return value of new.
- Adhere to convention when writing new.
- Avoid hiding the global new.
- Write delete if you write new.
- Define a copy constructor and an assignment operator for classes with dynamically allocated memory.
- Prefer initialization to assignment in constructors.
- List members in an initialization list in the order in which they are declared.
- Make destructors virtual in base classes.
- Have operator= return a reference to *this.
- Assign to all data members in operator=.
- Check for assignment to self in operator=.
- Strive for class interfaces that are complete and minimal.
- Differentiate among member functions, global functions and friend functions.
- Avoid data members in the public interface.
- Use const whenever possible.
- Pass and return objects by reference instead of by value.
- Don't try to return a reference when you must return an object.
- Choose carefully between function overloading and parameter defaulting.
- Avoid overloading on a pointer and a numerical type.
- Guard against potential ambiguity.
- Explicitly disallow use of implicitly generated member functions you don't want.
- Use structs to partition the global namespace.
- Avoid returning "handles to internal data from const member functions.
- Avoid member functions that return pointers or references to members less accessible than themselves.
- Never return a reference to a local object or a dereferenced pointer initialized by new within the function.
- Use enums for integral class constants.
- Use inlining judiciously.
- Minimize compilation dependencies between files.
- Make sure public inheritance models "isa."
- Differentiate between inheritance of interface and inheritance of implementation.
- Never redefine an inherited nonvirtual function.
- Never redefine an inherited default parameter value.
- Avoid casts down the inheritance heirarchy.
- Model "has-a" or "is-implemented-in-terms-of" through layering.
- Use private inheritance judiciously.
- Differentiate between inheritance and templates.
- Use multiple inheritance judiciously.
- Say what you mean; understand what you're saying.
- Know what functions C++ silently writes and calls.
- Prefer compile-time and link-time errors to runtime errors.
- Ensure that global objects are initialized before they're used.
- Pay attention to compiler warnings.
- Plan for coming language features.
- Read the ARM.
we specialize in Intelligent Business Rule Management Systems (iBRMS) - the same thing that used to be called rulebased systems by the AI companies.
|