Tutorials

OO PHP Part 3: UML, Classes and Relations

by John Kleijn on Jun 21, 2008 7:09:14 AM

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.

Comments

For starters, I absolute love these tutorials. They go beyond just OO syntax to best practices and application design.
On a different note, you mentioned you would provide a list of free UML editor, but I haven't found this list.

1. judahtanthony on Jun 27, 2008 1:23:04 PM

Thanks. I forgot about that. Will rectify, later.

2. John Kleijn on Jun 28, 2008 11:50:41 AM

This is nice work. As a newcomer to PHP, this is easy for me to assimilate. Thanks.

3. loydster on Jun 30, 2008 2:04:53 PM

I'm glad you guys like it. I will be doing one more about Design Patterns before taking a break to work on a different project, after launch of that I will continue with part 5+ :)

4. John Kleijn on Jun 30, 2008 3:57:32 PM

Very well explained. Hope u'll write on the Observer pattern. How can we use that kind of pattern in php ?

5. abouchoud on Aug 21, 2008 8:56:38 AM
Login or register to post a comment.