Professional Documents
Culture Documents
Introducing UML 2
Version 2 of the Unified Modeling Language (UML2) provides many of the familiar
UML1 diagrams, upgrades several diagrams making them more expressive, and adds a
number of new diagrams to keep up with the changes in object-oriented development.
The diagrams are organized into two main categories. Structural diagrams show the static
structure of a set of modeling elements. Behavioral diagrams allow you to focus on the
functional aspects of objects from different perspectives. Figure 1 provides a
categorization of UML 2 diagrams.
Basically
Diagram Unchanged
Many Changes
Significant
Changes
Structural Behavioral
New
Use
Class Object Package Activity State Machine
Case
Composite Interaction
Structure
Protocol State Machine
Sequence Communication
Please note: Due to the newness of UML2, several example figures are copied from the
final UML2 Superstructure submission to the Object Management Group
(www.omg.org). When you see a figure with a double asterisk after the caption (**), then
the figure was copied from the 3rd revised submission to OMG RFP ad/00-09-02 for the
Unified Modeling Language: Superstructure Version 2. The page reference at the end of
each figure caption with double asterisks is the page number in the UML2 Superstructure
submission where the original figure may be found. The submission date is April 10,
2003. Copyright © 2001-2003 U2 Partners (www.u2-partners.org), including content
adapted from the OMG Unified Modeling Language Specification v. 1.4. Copyright ©
1997-2001 Object Management Group (www.omg.org).
Class Diagram
The class diagram of UML2 has changed little from UML1. You will find all the familiar
modeling elements — classes, attributes, operations, associations, multiplicity, roles,
qualifiers, and association classes.
Component Diagram
When UML1 was first defined, component based design had not really gotten started.
UML2 had to address this issue and allow modelers and developers to explicitly show
components and how those components are wired together — thus the component
diagram. A component is defined as a replaceable unit with well defined interfaces that
separate operation specification from their method realization. Examples of components
include subsystems, enterprise java beans, OCXs, or a web service. Looking beyond
software, components could also be hardware really any replaceable unit with well
defined interfaces.
Components are shown as class boxes with interface symbols (lollipops and sockets). A
lollipop symbol represents an interface that is provided by the component and a socket
symbol represents and interface that is required by the component (must be provided by
some other component).
Figure 3 shows a store component with an OrderEntry provided interface and an
Account required interface. The diagram also shows the internal composite structure of
the Store with the Order, Customer, and Product unnamed parts. You can also see the
ball and socket connector where the Order component requires a Person interface and
the Customer component provides a Person interface. The small icon in the upper right
hand corner indicates that the class is stereotyped as a component. You can also just use
«component» as the stereotype instead of the little component icon.
Object Diagram
There is nothing really new in object diagrams. Just show objects on diagrams the same
way you always have.
Package Diagram
Not much has changed with the UML package notation in UML2. Packages now have
there own diagram and the notation used to import elements of another package have
changed a little. Figure 4 shows the ShoppingCart package publicly importing the
elements of the Types package via the «import» dependency. ShoppingCart privately
imports the Auxiliary package via the «access» dependency. Thus the WebShop
package only imports the elements from ShoppingCart and Types due to the private
nature of the «access» dependency.
Activity Diagram
Activity Diagrams have changed to allow the modeler and the developer to express Petri
Nets. In UML2 most of the notation for activity diagrams is the same but activity
diagrams now have extra meaning. As Petri Nets these diagrams are more powerful at
expressing control flow, discrete object flow, and continuous object flow.
Figure 6 shows some of the basic notation for a complex Process Order activity. An
object, Requested Order, flows into this activity and kicks off a sub activity — Receive
Order. The small dot is the starting point for the Process Order activity and the bull’s-
eye is where the activity and all flows terminate. The diamond allows control to flow
based on a decision. The thick bar notation allows for forking the control flow in a
Jim Schardt © 2008 Educational Experiences. Page 5 of 13
concurrent way. The diamond merges and the thick bar joins control flows as well. An
object flow is also shown by the activity Send Invoices generating objects of the Invoice
class and which in turn flows on to the Make Payment activity. You can specify pre and
post conditions for an activity as well.
Sequence Diagram
Sequence Diagrams are significantly enhanced. The basic notation for objects and trace
lines looks the same. But, you now place a "frame" around the diagram. You can
reference or show mini sequence diagrams in a larger sequence diagram. And, you can
easily show alternative flows, optional flows, interaction, and a host of other flows in one
diagram.
Place a sequence diagram inside a frame with the “sd” keyword. Instead of having object
instances you have connectable parts of classes. They are much the same as object
instances for the purpose of interactions. You can show more complex sequences by
placing frames inside the main sequence diagram frame. Some of the “sequence
fragments you can use are:
• ref: a reference frame to another sequence diagram
• alt: show alternative sequences based on some constraint (see Figure 10)
• loop: show iteration over a set of event sequences
• par: show event sequences that can happen in parallel
• critical: show a region of event sequences that must happen.
Jim Schardt © 2008 Educational Experiences. Page 8 of 13
We are just getting started.
Timing Diagram
UML2 has a new diagram to help those that need to focus on timing — the Timing
Diagram. In this diagram you show the lifelines (objects/parts) on the side of the diagram.
Each object goes through some states and a timing line is used to show when and how
long the object can be in that state. You can also show messages being passed between
different objects in the diagram.
Miscellaneous Diagrams