Re: A Change In Terminology: Monomorphic Objects. Polymorphic Objects
Dave Harris wrote:
In headers, instead of code like:
#include "MySpecialControl.h"
struct MyDialog : Dialog {
MySpecialControl m_control;
// ...
};
I am likely to have:
struct MySpecialControl;
struct MyDialog : Dialog {
MySpecialControl *m_pControl;
// ...
};
So that client code can #include "MyDialog.h" without getting a dependency
on MySpecialControl.h. This kind of dependency management is important for
large projects.
Yes, the PIMP idiom. I have never liked it, especially if it is used
for the reason you mention. In fact, I seek every opportunity to
create precisely that dependency that you want to avoid. I want the
compiler to see the type that is MySpecialControl. I want the
compiler-generated constructor of MyDialog to auto-construct m_control.
I want the compiler-generated destructor to auto-desstruct m_control.
I want the compiler-generated assignment between two MyDialog's to
automatically assigned (correctly) m_control.
Some might say that not using PIMP will result in too many compilations
of too many files. I say, if you have a class such that, perturbing it
causes the compilation of 1000's of files, then there are one of two
possibilities:
1. The included class is fundamental, and therefore the compilations
are warranted.
2. The organization of the code is poor, and should be restructured to
remove superfluous dependencies.
I think that the extra wait for the compilation to finish after the
perturbation of a critical class is by far the lesser of two evils.
-Le Chaud Lapin-
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]