Major Physical Design Rules
- Keep class data private
- Avoid data with external linkage at file scope
Avoid free functions (except operator functions) at file scope in
avoid free functions with external linkage (including
operator functions) in .c files.
Avoid enumerations, typedefs, and constants at file scope in .h files.
Avoid using preprocessor macros in header files except as include guards.
Only classes, structures, unions, and free operator functions should
be declared at files scope in a .h file;
only classes, structures, unions, and inline (member or free
operator) functions should be defined at file scope in a
Place a unique and predictable (internal) include guard around the contents
of each header file.
Logical entities declared within a component should not be defined
outside that component.
The .c file of every component should include its own .h
file as the first substantive line of code.
Avoid definitions with external linkage in the .c file of a component
that are not declared explicitly in the corresponding .h file.
Avoid accessing a definition with external linkage in another
component via a local declaration;
instead, include the .h file for that component.
Prepend every global identifier with its package prefix.
Prepend every source file name with its package prefix.
Avoid cyclic dependencies among packages.
Only the .c file that defines main is authorized to redefine global
new and delete.
Provide a mechanism for freeing any dynamic memory allocated to static
constructs within a component.