[Exceptional C++ Style] Item 14: Order, Order!

Herb Sutter hsutter at microsoft.com
Sun Dec 12 17:46:45 EST 2004


>Inheritance is a significantly stronger coupling relationship than
>friendship. At least Herb is consistent in getting the ranking slightly
>wrong, as it this ranking is mentioned in other books.

When I say that friendship is the strongest relationship, I'm thinking
of the dependency on the class's members. Regular code depends only on
the public parts, derived classes depend on the public and protected
parts, and friends depend on the public, protected, and private parts.

So I argue that it is the strongest relationship, while agreeing with
the following that it is not the most pervasively visible relationship.
There's a difference between being the strongest link and being the most
consequential/visible link.

>Just examine the
>consequence of the two relationships on a real (or indeed, imagined)
>source base and see what happens. The effect of ill-considered
>inheritance is far more pronounced than ill-considered friendship, and
>likewise the effect of any changes.

I agree with that, and diss unnecessary inheritance more often than I
diss unnecessary friendship.

Herb





More information about the Effective-cpp mailing list