UML Stereotypes applied to Class Inheritance design pattern

1.8k views Asked by At

While using Papyrus (+Eclipse), I faced an issue that I initially considered as an inconsistency. But after wondering about it, I started to think that I may have a "bug" in my basic concepts of UML designing.

Well, consider the basic Class Inheritance problem where Man and Woman are specializations of Person. (other words, Person is a superclass of Man and Woman).

Then, if you apply a Stereotype Worker (containing parameters job and salary, for example) to the Person, shouldn't the subclasses also receive the same stereotype Worker? Shouldn't they contain job and salary parameters?

I really though Stereotypes were also inherited from the superclass, but when I implement this design in Papyrus tool, I can't see any inherited job or salary. Every subclass is the same as if it didn't have any applied Stereotype.

Thanks in advance!

======================Edited for more information ========================

I found that an issue was opened in 2000 for the UML v1.3 regarding the inheritance of stereotypes in subclasses.

Issue 3210: Inheritance of Stereotypes (uml-rtf)

In my interpretation, the example provided in the Discussion is exactly what I asked above. However, it seems that the Reviewer understood that the issue was asking for subtype of Stereotype, and not propagation of Constraints from a stereotyped class to its subclasses.

This is the point added to the UML v1.3:

Stereotypes are GeneralizableElements. If a stereotype is a subtype of another stereotype, then it inherits all of the constraints and tagged values from its stereotype supertype and it must apply to the same kind of base class. A stereotype keeps track of the base class to which it may be applied.

Later on, it was deprecated in the UML v1.4 and removed in UML 2.

So, basically, according to my interpretation, the question existed... but the UML specs still don't specify it.

1

There are 1 answers

2
vainolo On BEST ANSWER

I also think that stereotypes are inherited, but I could not find any reference to this in the web or in the UML standard regarding this point. But from your description you should probably use either multiple inheritance or interfaces.

Stereotypes are used to extend the class - give more properties to the class element, and not to the instances. A class in UML has a name, properties (fields), and methods. When you add a stereotype to the class, you are actually adding another set of properties to the class. For example if you are writing an MVC (Model-View-Controller) system, and you want to specify which classes are the views, which are the models and which the controllers, using stereotypes would be a good answer since you are describing a property of the class, and not of specific instances. This doesn't seem to be your case.