I'm confused about the difference between something being a "stereotype" and being a "superclass" in UML.
Let's say I want to create a diagram involving a "WidgetMaker
." WidgetMaker
is clearly an Actor
so the UML standard is to stereotype it actor:
<<Actor>> WidgetMaker
But I grew up programming in the Java/Ruby/C++ world. In that world, the relationship is:
class Actor
end
class WidgetMaker < Actor
end
That looks like this in UML:
Actor
^
|
WidgetMaker
So my question is: why does UML have stereotypes at all when you can just as easily model those concepts using class inheritance, which it also has.
Once we have more "kinds" of actors, the question becomes even murkier:
Actor
^
|
------------------------
| | |
Person Robot Group
^
|
WidgetMaker
versus
<<Actor>> <<Person>> WidgetMaker
In your example Actor probably doesn't need to be implemented as a class, but this may or not always be the case. Stereotype are abstractions that can be applied to most UML elements not just classes.
They encapsulate semantics without implying how those semantics will provided. Another example could be a communications channel stereotyped as HTTP or RPC. They are communicating with the reader how something will be provided without complicating the model with unnecessary detail.
The UML specification provides a number of predefined stereotype, but their real power comes from being able to define your own through profiles. You might label a domain object as an EJB to save yourself specifying all the boiler plate code.