Good expansion of the code Patrick, as it shows how
process can flow though the
aggregated objects, however, there is one thing I would
like to comment on.
> >
> >class Lamp :
public Light,
>
> mixin
Body cBody,
>
> mixin
Switch cSwitch,
>
> mixin
Globe cGlobe,
>
> mixin
PowerCord cPowerCord
> >{
> >public:
>
> Lamp() : Light(), cBody(),
cSwitch(cPowerCord,cGlobe), cGlobe(), cPowerCord() {}
> >}
>
>
Versus
> class Lamp : public Light {
> public:
>
Lamp() {}
>
> private:
>
mixin Body
cBody;
> mixin
Switch cSwitch(cPowerCord,cGlobe);
>
mixin Globe
cGlobe;
> mixin PowerCord
cPowerCord;
> }
Originally, I too had the your later syntax, but changed
it the the former for the reasons;
1. Most object diagrams show aggregated
objects as external objects, not internal. For example;
2. In your example, you have placed (correctly
may I say) the aggreagated objects as private.
However, the code is
accessing methods of these objects as though they were public.
By
placing the object declarations outside of the
class, they can assume their original
access status.
3. As there will be many C++ programs that
have been using MI for aggregation techniques,
it would be easier to port
these to D if their syntax was to remain similiar in
structure.
I myself fit firmly in the the last categor. There is
slabs and slabs of C++ code that I would
like to correct the invalid use of
Multiple Inheritance to perform Agregation operations.
Criticism/Comments ?