Unified Modeling Language
Unified Modeling Language
Chapter5
Person
Name: Character
Height: meters
Person
Work()
Sleep()
Name: Character
Height: meters
Object Diagram
A static object diagram is an instance of a
class diagram.
It shows a snapshot of the detailed state of
the system at a point in time.
Notation is the same for an object
diagram and a class diagram.
Class diagrams can contain objects, so a
class diagram with objects and no classes
is an object diagram.
Object Oriented Systems Development 25
Class Interface Notation
Class interface notation is used to describe
the externally visible behavior of a class; for
example, an operation with public visibility.
The UML notation for an interface is a small
circle with the name of the interface
connected to the class.
A class that requires the operations in the
interface may be attached to the circle by a
dashed arrow.
The dependent class is not required to
actually use all of the operations.
55
The three representations of an actor are equivalent.
USE-CASE DIAGRAM
These relationships are shown in a use-case
diagram:
◦ Communication. The communication relationship
of an actor in a use case is shown by connecting
the actor symbol to the use-case symbol with a
solid path. The actor is said to "communicate"
with the use case.
◦ Uses. A uses relationship between use cases is
shown by a generalization arrow from the use
case.
◦ Extends. The extends relationship is used when
you have one use case that is similar to another
use case but does a bit more. In essence, it is like
a subclass. 57
UML DYNAMIC MODELING
(BEHAVIOR DIAGRAMS)
The diagrams we have looked at so far
largely are static.
However, events happen dynamically in all
systems: Objects are created and destroyed,
objects send messages to one another in an
orderly fashion, and in some systems,
external events trigger operations on certain
objects.
Furthermore, objects have states.
The state of an object would be difficult to
capture in a static model.
UML DYNAMIC MODELING
(BEHAVIOR DIAGRAMS)
One can express the dynamic semantics
of a problem with the following diagrams:
Behavior diagrams (dynamic):
◦ Interaction diagrams:
Sequence diagrams
Collaboration diagrams
◦ Statechart diagrams
◦ Activity diagrams
UML Interaction Diagrams
Interaction diagrams are diagrams that
describe how groups of objects
collaborate to get the job done.
Interaction diagrams capture the
behavior of a single use case, showing the
pattern of interaction among objects.
There are two kinds of interaction
models: sequence diagrams and
collaboration diagrams.
UML Sequence Diagram
Sequence diagrams are an easy and intuitive
way of describing the behavior of a system
by viewing the interaction between the
system and its environment.
A sequence diagram shows an interaction
arranged in a time sequence.
It shows the objects participating in the
interaction by their lifelines and the
messages they exchange, arranged in a time
sequence.
UML Sequence Diagram
A sequence diagram has two dimensions:
the vertical dimension represents time, the
horizontal dimension represents different
objects.
The vertical line is called the object's
lifeline.
The lifeline represents the object's
existence during the interaction.
UML Sequence Diagram
An object is shown as a box at the top of
a dashed vertical line.
A sequence diagram does not show the
relationships among the roles or the
association among the objects.
An object role is shown as a vertical
dashed line, the lifeline.
UML Sequence Diagram
UML Sequence Diagram
Each message is represented by an arrow
between the lifelines of two objects.
The order in which these messages occur is
shown top to bottom on the page.
Each message is labeled with the message
name.
The label also can include the argument and
some control information and show self-
delegation, a message that an object sends to
itself, by sending the message arrow back to
the same lifeline.
UML Sequence Diagram
The sequence diagram is very simple and
has immediate visual appeal—this is its
great strength.
A sequence diagram is an alternative way
to understand the overall flow of the
control of a program.
UML Collaboration Diagram
Another type of interaction diagram is the
collaboration diagram.
A collaboration diagram represents a
collaboration, which is a set of objects
related in a particular context, and
interaction, which is a set of messages
exchanged among the objects within the
collaboration to achieve a desired
outcome.
UML Collaboration Diagram
In a collaboration diagram, the sequence
is indicated by numbering the messages.
A collaboration diagram provides several
numbering schemes.
UML Collaboration Diagram
Here 1.2: DialNumber means that the Caller
(1) is calling the Exchange (2); hence, the
number 1.2. The UML uses the decimal
scheme because it makes it clear which
operation is calling which other operation,
although it can be hard to see the overall
sequence
The disadvantage of interaction diagrams is
that they are great only for representing a
single sequential process; they begin to break
down when you want to represent complex
behavior
UML Statechart Diagram
A statechart diagram (also called a state
diagram) shows the sequence of states that an
object goes through during its life in
response to outside stimuli and messages.
The state is the set of values that describes an
object at a specific point in scope and is
represented by state symbols and the
transitions are represented by arrows
connecting the state symbols.
The statechart diagram may contain
subdiagrams.
Object Oriented Systems Development 74
UML Statechart Diagram
A state is represented as a rounded box, which
may contain one or more compartments.
The compartments are all optional.
The name compartment and the internal transition
compartment are two such compartments:.
◦ The name compartment holds the optional name of
the state.
◦ States without names are "anonymous" and all are
distinct.
◦ Do not show the same named state twice in the same
diagram, since' it will be very confusing.
Start Dial
Entry and start Entry and
dialog. Exit & number.append(n)
stop dial tone
Digit(n)
UML Statechart Diagram
The transition can be simple or complex.
A simple transition is a relationship
between two states indicating that an
object in the first state will enter the
second state and perform certain actions
when a specific event occurs, if the
specified conditions are satisfied, the
transition is said to "fire."
i j
A B
k l
Package