Boost logo

Boost :

From: Stefan Slapeta (stefan_at_[hidden])
Date: 2006-05-31 03:07:53


Maarten Kronenburg wrote:
>
> For an abstract base class, derivation is mandatory.
> This is not what I want, because I want non-demanding
> users to be able to use the class integer without derivation.
> On the other hand I also want demanding users to be able
> to use derivation for defining integers with specific properties
> such as an unsigned_integer or a modular_integer,
> and use mixed expressions.
> When I make the class concrete then users will never
> be able to derive from it, unless they make a new class
> with an integer data member and start all over again.
> I have thought this through, and I think the way it is,
> it serves both non-demanding and demanding users
> best with flexibility if needed.
>

Sorry, but 'configuration by inheritance' is by far the worst OO design
'idea' that has ever been invented by human being. It inhibits reuse
instead of encouraging it and it's responsible for most of the problems
in large OO systems I've seen so far. Furthermore, it's a completely
wrong interpretation of inheritance.
C++ provides perfect techniques to achieve what you want: templates and
static configuration are very powerful tools to provide both flexibility
and good design.

Stefan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk