Membership
Main Menu
Forum Boards
Stats
- 20 tutorials
- 74,664 members
- 732,687 forum posts
- 13 blog posts
Tutorials
OO PHP Part 3: UML, Classes and Relations
Views: 36374
4. Stereotypes
The OMG UML specification states:
"A stereotype is, in effect, a new class of metamodel element that is introduced at modeling time. It represents a subclass of an existing metamodel element with the same form (attributes and relationships) but with a different intent. Generally a stereotype represents a usage distinction..."
Stereotypes introduce distinctions between (types of) model elements, by sub-classification of model elements. Like the bold text in the quote notes, this is usually a usage distinction. When talking about elements, I am referring to UML entities that have a single representation in the model, like classes and associations.
UML has predefined stereotypes, and it permits the use of custom (user defined) stereotypes that are not supported by the UML metamodel. Some build-in ones we already encountered: interface, implementation and realize.
Applying a stereotype can be compared to applying inheritance in OOP. When a stereotype is applied, a specialized model element is created: when I apply the stereotype <<interface>> to a class without attributes, it represents an interface. When I apply the stereotype <<framework>> to a package, it represents a framework. Pretty simple actually, right?
Ok, so I simplified it a whole bit. More information about the UML ‘four-layer metamodel architecture’ can be found here, I’m not covering it in this article. Most UML editors ignore the semantics described by the UML specification, more information in this excellent thesis.
