Home > Enterprise >  UML:Inheritance between template classes with parameter dependencies
UML:Inheritance between template classes with parameter dependencies

Time:10-17

Pardon my poor english. Just let me show you the situation what I'm trying to draw in UML class diagram.

template<typename TB1, typename TB2, typename TB3>
class Base { ... };

template<typename TD1, typename TD2>
class Derived : public Base<typename TD1, typename TD2, int> { .... };

I know how to draw UML class diagram when a class inherits generic class, as below(enter image description here

It corresponds to the C semantics. But the UML section 9.9.3.2 Template classifier specializations gives another semantic to this diagram:

A RedefinableTemplateSignature redefines the RedefinableTemplateSignatures of all parent Classifiers that are templates. All the formal TemplateParameters of the extended (redefined) signatures are included as formal TemplateParameters of the extending signature, along with any TemplateParameters locally specified for the extending signature.

I understand this as meaning that the template parameters increase (i.e. the set would be TB1, TB2, TB3, TD1 and TD2) and there is no semantics nor notation foreseen to define a local binding of some parents elements. So UML readers might misunderstand the design intent.

Option 3 - binding and inheritance

The cleanest way would therefore be to decompose the binding and the inheritance (I've used a bound class that is itself templated with the new parameter name to align, but this could be overkill) :

enter image description here

  • Related