TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C++ Coding Standard

Rule:  ORG#009

Synopsis:Avoid unnecessary inclusion
Severity Level:6
Category:Code Organization


Do not include any header files that are not used by the including file.

Consider to use "compilation firewalls" such as abstract base classes and the so-called "pimpl" programming idiom to reduce unnecessary compile-time coupling (see [ORG#004]).

Consider to use forward declarations of incomplete types. These declarations shall then be localized in the "__fwd.h" header of a certain module. This not only prevents the occurrence of such type declarations in headers with the wrong basename, but also makes such dependencies much more explicit and traceable by means of an #include directive. Furthermore, the localization of forward declarations in "__fwd.h" headers makes it possible to hide whether a class name is a class template instantiation or not.

Literature References:
ISC++ Rule 2.2