From the UML superstructure 2.2 [edit](7.3.55 VisibilityKind (from Kernel))[/edit]
- A protected element is visible to elements that have a generalization relationship to the namespace that owns it.
This concept isn't really supported in C++, IMHO. There's no visibility (scope) specifier attribute on level of a classes declaration. There's a weak visibility relation to the namespace owning the class, yes. But it doesn't hide anything from the public, just from other namespaces default scope. In C# (and I think in Java too), you can specify a classifiers visibility, but you can't specify visibility of the superclasses and interfaces you inherit.
In the same chapter UML 2.2. Superstructure also says:
Notation
The following visual presentation options are available for representing VisibilityKind enumeration literal values:
- ‘+’ public
- ‘-’ private
- ‘#’ protected
- ‘~’ package
But this isn't supported by EA as far I've seen (I guess this decoration should optionally prefix the element's name, right?).
About the 'has a'/'is a', 'composition' vs. 'inheritance' discussion:
Citing from the C++ light FAQ as a good, reliable and recommendable source,
section 24.3 ... A legitimate, long-term use for private inheritance ..., better describes my designs situation. I'm pretty sure I wanna have an 'is a' here: I want to realize an interface, since I can't hide the interface itself in C++, as I would do in C# for example, I'm factoring out the implementation to another class, and replace the implementation by protected or private inheritance.
I mentioned that I was starting with a <<friend>> dependency, where the buddy class needed access to some of a classes protected/private operations. In fact, the buddy classes are the facades and I want to urge clients to use these instead of certain (hidden) interfaces.
Compared vs. composition, the inheritance may also have impact on the efficiency of the implementation. Using the CRTP (aka. static polymorphism) to realize the interface, you may end up with zero cost for footprint (data & code!) or performance (I'm working with embedded devices, you know).
I can live with the constraint. May be it's making it even more clear for the already cited average common-or-garden developer, than yet another subtle UML notational decoration (YASUND ?? ;D).
WBR & thanks for the vivid discussion so far,
Günther