Section 1.7. A First Taste of UML


1.7. A First Taste of UML

Before 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 and stereotypes .

1.7.1. Notes

Notes 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 note


Notes 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 line


In 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. Stereotypes

Stereotypes 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 stereotype


There 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 icon


There 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 person


The UML specification defines a set of "standard" or predefined stereotypes. Some of the more useful standard stereotypes include:

1.7.2.1. Stereotype applied to classes (see Chapters 4 and 5)

utility

Represents a class that provides utility services through static methods, just as Java's Math class.

1.7.2.2. Stereotypes applied to components (see Chapter 12)

service

A stateless, functional component that computes a value; could be used to represent a web service.


subsystem

A large component that is actually a subordinate system of a larger system.

1.7.2.3. Stereotypes applied to artifacts (see Chapter 15)

executable

A physical file that is executable, such as an .exe file.


file

A physical file used by your system; this could be a configuration file such as a .txt file.


library

A static or dynamic library file; you could use this to model .dll or .jar library files.


source

A source file containing code, such as a .java or .cpp file.

1.7.2.4. Tagged values

Stereotypes 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


In UML 2.0, stereotypes and their tagged values are defined using profiles. To learn more about stereotypes and how to create roles for the elements of your model, see Appendix B.





Learning UML 2.0
Learning UML 2.0
ISBN: 0596009828
EAN: 2147483647
Year: 2007
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net