1.7. A First Taste of UMLBefore jumping into the different types of diagrams that make up UML, you need to know about two elements of UML notation that are used throughout a model: notes 1.7.1. NotesNotes allow you to enter additional comments that aren't captured in your diagrams. You can write anything you want in a note to explain your diagram, similar to a comment in code. Notes are pictured with the folded rectangle notation as shown in Figure 1-8. Figure 1-8. A UML noteNotes can be placed on a diagram in isolation or attached to a specific part of the diagram as shown in Figure 1-9. Figure 1-9. A note is attached to another element on the diagram using a dotted lineIn this book, notes are used to explain something more about a particular diagram. Notes are just aids for the reader of a diagram; they don't change the meaning of the diagram or the underlying model at all. 1.7.2. StereotypesStereotypes signify a special use or intent and can be applied to almost any element of UML notation. Stereotypes modify the meaning of an element and describe the element's role within your model. A stereotype sometimes has an associated icon, such as in Figure 1-10's stick-figure actor symbol. To learn more about actors, see Chapter 2. Figure 1-10. The Administrator is represented in the role of an actor because it is using the stick figure notation associated with that stereotypeThere isn't always a special icon for a stereotype; sometimes they take up too much room and clutter a diagram. In these cases, the stereotype is shown using guillemots at either end of the stereotype name, as in «stereotype_name», shown in Figure 1-11. However, because guillemots require an extended character set, you can substitute them for angle brackets, as in <<stereotype_name>>. Figure 1-11. The Administrator element is still an actor, but its stereotype is now specified using a name rather than an iconThere is no limit to the number of stereotypes with which an element can be associated; sometimes you may end up specifying more than one stereotype, as shown in Figure 1-12. Figure 1-12. The Administrator is now stereotyped as an actor and a personThe UML specification defines a set of "standard" or predefined stereotypes. Some of the more useful standard stereotypes 1.7.2.1. Stereotype applied to classes (see Chapters 4 and 5)
1.7.2.2. Stereotypes applied to components (see Chapter 12)
1.7.2.3. Stereotypes applied to artifacts (see Chapter 15)
1.7.2.4. Tagged valuesStereotypes can contain extra information that relates to the element to which they are applied. This extra information is specified using tagged values Tagged values are associated with a stereotype. Say you had an element in your model that represented a login page on a web site, and it was stereotyped as a form. The form stereotype needs to know whether it should validate the contents of the form or not in this case. This validation decision should be declared as a tagged value of the form stereotype because it is associated with the stereotype that is applied to an element, not with the element itself. A tagged value is drawn on a diagram using a similar notation to notes, but the folded rectangle contains the name of any stereotypes and settings for any associated tagged values. The tagged value note is then attached to the stereotyped element using a dotted line with a circle at the element end, as shown in Figure 1-13. (This example was adapted from UML 2.0 in a Nutshell [O'Reilly].) Figure 1-13. The form stereotype has an associated validate tagged value, which is set to true in this case
|
Tuesday, October 27, 2009
Section 1.7. A First Taste of UML
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment