SE Viva
SE Viva
In this chapter
Overview of the UML
Three steps to understanding the UML
Software architecture
The software development process
The UML is appropriate for modeling systems ranging from enterprise infor
mation systems to distributed Web-based applications and even to hard real
time embedded systems. It is avery expressive language, addressing allthe
views needed to develop and then deploy such systems. Even though it is
expressive, the UML is not difficult tO understand and to use. Learning to
apply the UML effectively starts with forming aconceptual model of the lan
guage, which requires learning three major elements:the UML's basic building
blocks, the rules that dictate how these building blocks may be put together,
and some common mechanisms that apply throughout the language.
13
14 PART 1 GETTING STARTED
Visualizing
Specifying
Constructing
Documenting
the artifacts of a software-intensive system.
In such cases, the programmer is still doing some nodeling, albeit entirely
mentally. He or she may even sketch out a few ideas on a white board or on a
napkin. However, there are several problems with this. First, communicating
those conceptual models to others is error-prone unless everyone involved
speaks the same language. Typically, projects and organizations develop their
own language, and it is difficult to understand what's going on if you are an
outsider or new to the group. Second, there are some things about a software
system you can't understand unless you build models that transcend the textual
programming language. For example, the meaning of aclass hierarchy can be
inferred, but not directly grasped, by staring at the code for all the classes in
the hierarchy. Similarly, the physical distribution and possible migration of the
objects in a Web-based system can be inferred, but not directly grasped, by
studying the system's code. Third, if the developer who cut the code never
Wrote down the models that are in his or her head, that information would be
lost forever or, at best, only partially recreatable from the implementation once
that developer movedon.
Writing models in the UML addresses the third issue: An explicit model facili
tates communication.
Some things are best modeled textually; others are best modeled graphically.
Indeed, in all interesting systems, there are structures that transcend what can
be represented in a programming language. The UML is such a graphical lan
guage. This addresses the second problem described earlier.
The complete The UML is more than just a bunch of graphical symbols. Rather, behind each
semantics of symbol in the UML notation is a well-defined semantics. In this manner, one
the UML are developer can write a model in the UML, and another developer, or even
discussed in
The Unified another tool, can interpret that model unambiguously. This addresses the first
Modeling Lan issue described earlier.
guage Refer
ence Manual,
The UML Is aLanguage for Specifying
precise, unambigu
In this context, specifying means building models thatthearespecification of all the
Ous, and complete. In particular, the UML addresses that must be made in
Important analysis, design, and implementation decisions
developing and deploying a software-intensive system.
Things are the abstractions that are first-class citizens in a model; relationships
tie these things together; diagrams group interesting collections of things.
GETTING STARTED
PART 1
18
Window
origin
size
open)
close()
move()
display()
Figure 2-1:Classes
Interfaces are An interface is a collection of operations that specify a service of a class or
discussed in component. An interface therefore describes the externally visible behavior of
Chapter 11.
that element. An interface might represent the complete behavior of a class or
component or only apart of that behavior. An interface defines a set of opera
tion specifications (that is,their signatures) but never a set of operation imple
mentations. The declaration of an interface looks like a class with the keyword
<interface» above the name; attributes are not relevant, except sometimes to
show constants. An interface rarely stands alone, however. An interface pro
vided by a class to the outside world is shown as a small circle attached to the
class box by a line. An interface required by a class from some other class is
shown as a small semicircle attached to the class box by a line, as in
Figure 2-2.
CHAPTER2 INTRODUCING THE UML 19
einterface»
IWindow
open()
close()
move()
display()
Window
IWindow IPaint
Collaborations Acollaboration defines an interaction and is asociety of roles and other ele
are discUssed
ments that work together to provide some cooperative behavior that's bigger
in Chapter 28. than the sum of all the elements. Collaborations have structural, as well as
behavioral, dimensions. A given class or object might participate in several
collaborations. These collaborations therefore represent the implementation of
patterns that make up a system. Graphically, a collaboration is rendered as an
ellipse with dashed lines, sometimes including only its name, as in Figure 2-3.
Chain of
responsibility
Use cases are A use case is a description of sequences of actions that a system performs that
discussed in yield observable results of value to a particular actor. Ause case is used to
Chapter 17. structure the behavioral things in a model. A use case is realized by a collabo
ration. Graphically, a use case is rendered as an ellipse with solid lines, usually
including only its name, as in Figure 2-4.
Place order
different enough and are necessary for modeling certain aspects of an object-
treatment.
oriented system, so they warrant special
An gctiveclass is a class whose objects oWn one OT more processes or threads
Active classes
are discussed and therefore can initiate control activity. An active class is just like a class
with
in Chapter 23. except that its objects represent elements whose behavior is concurrent
other elements. Graphically, an active class is rendered as a class with double
lines on the left and right; it usually includes its name, attributes, and opera
tions, as in Figure 2-5.
EventManager
suspend)
flush()
Components Acomponentis a modular part of the system design that hides its implementa
and internal
structure are
tion behind aset of external interfaces. Within a system, components shar1ing
discussed in the same interfaces can be substituted while preserving the same logical
Chapter 15. behavior. The implementation of a component can be exxpressed by wifing
together parts and connectors; the parts can include smaller components.
Graphically, acomponent is rendered like a class with a special icon in he
upper right corner, as in Figure 2-6.
Orderform
«artifact»
window.dll
Server
State Second, a state machine is a behavior that specifies the sequences of states an
machines are object or an ineraction goes through during its lifetime in response to events,
discussed in together with its responses to those events. The behavior of an individual class
Chapter 22. or acollaboration of classes may be specified with a state machine. A state
machine involves a number of other elements, including states, transitions (the
flow from state to state), events (things that trigger a transition), and activities
(the response to atransition), Graphically, a state is renderedas a rounded rect
angle, usually including its name and its substates, if any, as in Figure 2-10.
Waiting
process order
Business rules
return copy
of self
1. Dependency
2. Association
3. Generalization
4. Realization
GETTING STARTED
PART 1
24
employer employee
Generalareiza Figure 2-15: Associations
tions Third, ageneralization isa
discussed in the
Chapters 5
and 10. izedspeci
el
parent.
ement specializsharesation/generstructure
alized(theelement (the child) builds on
parent). The child the aspecilizatiofincatrelationship
ion general
of the
in
which
holGrloawphiarrowhead
cally, generalization
with a a the and the behavior of the
pointing to therelaparent,
tionshipas inrendered as a solid line
is
Figure 2-10.
Realizations
are discussed
Fourt h, a Figure 2-16:Generalizations
in Chapter 10.
one realization is a
cll assifier specifies a semantic
You'
and encounter
the classes contract thatrelationship between
rthatcomponent
ealization rselthatationshianotps inhertwoclassiplaces:
wherein classifiers,
dered
Or
cFigureol abasor2-17.aatiocrossns realizeathem. realize them, and between interfaces fier guarantees
to carry out.
between
generalGrizataphiioncalandly, arealization relationship is ren-
betw een
a use cases and the
dependency relatosy
CHAPTER 2 INTRODUCING THE UML 25
The five views Diagrams in the UML Adiagram is the graphical presentation of a set of
of an architec elements, most often rendered as a connected graph of vertices (things) and
ture are
discussed later paths (relationships). You draw diagrams to visualize asystem from different
in this chapter. perspectives, so a diagram is aprojection into a system. For all but the most
trivial systems, a diagram represents an elided view of the elements that make
up a system. The same element may appear in all diagrams, only a few dia
grams (the most common case), or in no diagrams at all (a very rare case). In
theory, a diagram may contain any combination of things and relationships. In
practice, however, a small number of common combinations arise, which are
consistent with the five most useful views that comprise the architecture of
a software-intensive system. For this reason, the UML includes thirteen kinds
of diagrams:
1.Class diagram
2. Object diagram
3. Component diagram
4. Composite structure diagram
5. Use case diagram
6. Sequence diagram
7.Communication diagram
8. State diagram
9. Activity diagram
10. Deployment diagram -
11. Package diagram
12. Timing diagram
13. Interaction overview diagram
Class Aclass diagram shows aset of classes, interfaces, and collaborations and their
diagrams are
discussed in
relationships. These diagrams are the most common diagram found in model
Chapter 8.
ing object-oriented systems, Class diagrams address the static design view of a
system. Class diagrams that include active classes address the static process
view of a system.Component diagrams are variants of class diagrams.
Object An object diagram shows aset of objects and their relationships. Object dia
diagrams are grams represent static snapshots of instances of the things found in class dia
discussed in
Chapter 14.
grams. These diagrams address the static design view or static process view of
26 PART 1 GETTING STARTED
prototypical
a system as do class diagrams, but from the perspective of real or
cases.
Interaction Both sequence diagrams and communication diagrams are kinds of interaction
diagrams are
discussed in
diagrams. An interaction diagram shows an interaction, consisting of a set of
Chapter 19.
objects or roles,including the messagesthat may be dispatched among them.
Interaction diagrams address the dynanmic view of a system. A sequence dia
gram isan interaction diagram thatemphasizes the time-ordering of messages;
a communication diagram is an interaction diagram that emphasizes the struc
tural organization of the objects or roles that send and receive messages.
Sequence diagrams and communication diagrams represent similar basic con
cepts, but each diagram emphasizes a different view of the concepts. Sequence
diagrams emphasize emporal ordering, and communication diagrams empha
size the data structure through which messages flow. A timing diagram (not
covered in this book) shows the actual timnes at which messages are exchanged.
State A state diagram shows a state machine, consisting of states, transitions, eventS,
diagrams are
discussed in and activities. Astate diagrams shows the dynamic view of an object. They are
Chapter 25. especially important in modeling the behavior of an interface, class, or collab
oration and emphasize the event-ordered behavior of an object, which is espe
cially useful in mnodeling reactive systems.
Activity An activity diagram shows the structure of a process or other computation as
diagrams are the flow of control and data from step to step within the computation. Activiy
discussed in
Chapter 20 diagrams address the dynamic view of a system. They are especially importa
in modeling the function of a system and emphasize the flow of control among
objects.
Deployment A deployment diagram shows the configuration of run-time processing node
diagrams are and the components that live on them. Deployment diagrams address the static
discussed in
Chapter 31. deployment view of an architecture. A node typically hosts one or more aru
facts.
CHAPTER 2 INTRODUCING THE UML 27
Artifact
diagrams are
An artifact diagram shows the physical constituents of asystem on the com
discussed in
puter. Artifacts include files, databases, and similar physical collections of bits.
Chapter 30.
Artifacts are often used in conjunction with deployment diagrams. Artifacts
also show the classes and components that they implement. (UML treats arti
fact diagrams as a variety of deployment diagram, but we discuss them sepa
rately.)
Package dia Apackage diagram shows the decomposition of the model itself into organiza
grams are dis tion units and their dependencies.
CUSsed in
Chapter 12.
Atiming diagram is an interaction diagram that shows actual times across dif
ferent objects or roles, as opposed to just relative sequences of messages. An
interaction overview diagram is a hybrid of an activity diagram and a sequernce
diagram. These diagranms have specialized uses and so are not discussed in this
book. See the UML Reference Manual for more details.
This is not a closed list of diagrams. Tools may use the UML to provide other
kinds of diagrams, although these are the most common ones that you will
encounter in practice.