Item-31 Minimize compilation dependencies between files
· ☕ 9 min read
To minimize compilation dependencies, depend on declarations instead of definitions via techniques such as Handle classes and Interface classes.
To minimize compilation dependencies, depend on declarations instead of definitions via techniques such as Handle classes and Interface classes.
Limit most inlining to small, frequently called functions to facilitate debugging and binary upgradability, minimize potential code bloat, and maximize the chances of greater program speed.
Exception-safe functions leak no resources and allow no data structures to become corrupted, even when exceptions are thrown. Such functions offer the basic, strong, and nothrow guarantees.
Avoid returning handles to object internals to increase encapsulation, help const
member functions act const
, and minimize the creation of dangling handles.
Avoid casts and develop a cast-free alternative whenever practical, especially dynamic_cast
in performance-sensitive code.