Com 213 Unified Modelling Launguage Programming Theory
Com 213 Unified Modelling Launguage Programming Theory
VOCATIONAL EDUCATION
REVITALISATION PROJECT-PHASE II
NATIONAL DIPLOMA IN
COMPUTER TECHNOLOGY
(COM213)
YEAR 2-SEMESTER 1
THEORY
Version 1: December 2008
Pg 1
TABLE OF CONTENTS
Table of Contents
WEEK 1 OJECT ORIENTED TECHNIQUE....................................................................... 3
Overview............................................................................................................ 3
Fundamental concepts.................................................................................. 4
History ................................................................................................................ 7
WEEK 2 UNIFIED MODELLING LANGUAGE (UML) – The General Overview ............... 12
History .............................................................................................................. 12
Before UML 1.x .......................................................................................... 13
UML 1.x ........................................................................................................ 13
Development toward UML 2.0
............................................................... 14
Unified Modeling Language topics........................................................... 14
Methods........................................................................................................ 14
Modelling...................................................................................................... 15
Diagrams overview................................................................................... 15
WEEK 3-4
THE STRUCTURE DIAGRAM –....................................................................... 21
WEEK 5 COMPOSITE DIAGRAM....................................................................................... 42
WEEK 6 THE COMPONENT DIAGRAM.......................................................................... 48
WEEK 7 OBJECT AND PACKAGE DIAGRAM .................................................................. 56
WEEK 8 DEPLOYMENT ...................................................................................................... 60
WEEK 9 THE BEHAVIOUR DIAGRAM........................................................................... 64
WEEK 10 THE USE CASE MODEL.................................................................................... 73
WEEK 11 THE STATE MACHINE MODEL....................................................................... 79
WEEK 12 THE INTERACTION DIAGRAM....................................................................... 89
WEEK 13 THE INTERACTION OVERVIEW DIAGRAMAn interaction overview
diagram is a form of activity diagram in which the nodes represent
interaction diagrams...................................................................................... 101
WEEK 14 THE UML TOOLS ................................................................................................ 106
Features in UML Tools....................................................................... 106
Popular UML Tools............................................................................... 109
Integration of UML Tools with Integrated Development
Environments (IDEs)......................................................................... 111
WEEK 15 CASE TOOL APPLICATION............................................................................. 112
Pg 2
WEEK One
OJECT ORIENTED TECHNIQUE
Introduction
Overview
Pg 3
Fundamental concepts
Class
Defines the abstract characteristics of a thing (object),
including the thing's characteristics (its attributes, fields or
properties) and the thing's behaviors (the things it can do,
or methods, operations or features). One might say that a
class is a blueprint or factory that describes the nature of
something. For example, the class Dog would consist of traits
shared by all dogs, such as breed and fur color
(characteristics), and the ability to bark and sit (behaviors).
Classes provide modularity and structure in an object-oriented
computer program. A class should typically be recognizable to
a non-programmer familiar with the problem domain,
meaning that the characteristics of the class should make
sense in context. Also, the code for a class should be
relatively self-contained (generally using encapsulation).
Collectively, the properties and methods defined by a class
are called members.
Object
A pattern (exemplar) of a class. The class of Dog defines all
possible dogs by listing the characteristics and behaviors they
can have; the object Lassie is one particular dog, with
particular versions of the characteristics. A Dog has fur; Lassie
has brown-and-white fur.
Instance
One can have an instance of a class or a particular object. The
instance is the actual object created at runtime. In
programmer jargon, the Lassie object is an instance of the
Dog class. The set of values of the attributes of a particular
object is called its state. The object consists of state and the
behaviour that's defined in the object's class.
Method
An object's abilities. In language, methods are verbs. Lassie,
being a Dog, has the ability to bark. So bark() is one of Lassie's
methods. She may have other methods as well, for example
sit() or eat() or walk() or save_timmy(). Within the program, using
a method usually affects only one particular object; all Dogs
can bark, but you need only one particular dog to do the
barking.
Message passing
Pg 4
“The process by which an object sends data to another object
or asks the other object to invoke a method.” [1] Also known
to some programming languages as interfacing. E.g. the
object called Breeder may tell the Lassie object to sit by passing
a 'sit' message which invokes Lassie's 'sit' method. The syntax
varies between languages, for example: [Lassie sit] in
Objective-C. In Java code-level message passing corresponds
to "method calling". Some dynamic languages use double-
dispatch or multi-dispatch to find and pass messages.
Inheritance
‘Subclasses’ are more specialized versions of a class, which
inherit attributes and behaviors from their parent classes, and
can introduce their own.
For example, the class Dog might have sub-classes called
Collie, Chihuahua, and GoldenRetriever. In this case, Lassie would
be an instance of the Collie subclass. Suppose the Dog class
defines a method called bark() and a property called furColor.
Each of its sub-classes (Collie, Chihuahua, and GoldenRetriever)
will inherit these members, meaning that the programmer
only needs to write the code for them once.
Each subclass can alter its inherited traits. For example, the
Collie class might specify that the default furColor for a collie is
brown-and-white. The Chihuahua subclass might specify that
the bark() method produces a high pitch by default. Subclasses
can also add new members. The Chihuahua subclass could add
a method called tremble(). So an individual chihuahua instance
would use a high-pitched bark() from the Chihuahua subclass,
which in turn inherited the usual bark() from Dog. The
chihuahua object would also have the tremble() method, but
Lassie would not, because she is a Collie, not a Chihuahua. In
fact, inheritance is an ‘is-a’ relationship: Lassie is a Collie. A
Collie is a Dog. Thus, Lassie inherits the methods of both Collies
and Dogs.
Multiple inheritance is inheritance from more than one
ancestor class, neither of these ancestors being an ancestor of
the other. For example, independent classes could define Dogs
and Cats, and a Chimera object could be created from these
two which inherits all the (multiple) behavior of cats and
dogs. This is not always supported, as it can be hard both to
implement and to use well.
Abstraction
Abstraction is simplifying complex reality by modelling classes
appropriate to the problem, and working at the most
appropriate level of inheritance for a given aspect of the
problem.
For example, Lassie the Dog may be treated as a Dog much of
the time, a Collie when necessary to access Collie-specific
Pg 5
attributes or behaviors, and as an Animal (perhaps the parent
class of Dog) when counting Timmy's pets.
Abstraction is also achieved through Composition. For
example, a class Car would be made up of an Engine,
Gearbox, Steering objects, and many more components. To
build the Car class, one does not need to know how the
different components work internally, but only how to
interface with them, i.e., send messages to them, receive
messages from them, and perhaps make the different objects
composing the class interact with each other.
Encapsulation
Encapsulation conceals the functional details of a class from
objects that send messages to it.
For example, the Dog class has a bark() method. The code for
the bark() method defines exactly how a bark happens (e.g.,
by inhale() and then exhale(), at a particular pitch and volume).
Timmy, Lassie's friend, however, does not need to know
exactly how she barks. Encapsulation is achieved by
specifying which classes may use the members of an object.
The result is that each object exposes to any class a certain
interface — those members accessible to that class. The
reason for encapsulation is to prevent clients of an interface
from depending on those parts of the implementation that are
likely to change in future, thereby allowing those changes to
be made more easily, that is, without changes to clients. For
example, an interface can ensure that puppies can only be
added to an object of the class Dog by code in that class.
Members are often specified as public, protected or
private, determining whether they are available to all
classes, sub-classes or only the defining class. Some
languages go further: Java uses the default access modifier
to restrict access also to classes in the same package, C# and
VB.NET reserve some members to classes in the same
assembly using keywords internal (C#) or Friend (VB.NET),
and Eiffel and C++ allow one to specify which classes may
access any member.
Polymorphism
Polymorphism allows the programmer to treat derived class
members just like their parent class' members. More
precisely, Polymorphism in object-oriented programming is
the ability of objects belonging to different data types to
respond to method calls of methods of the same name, each
one according to an appropriate type-specific behavior. One
method, or an operator such as +, -, or *, can be abstractly
applied in many different situations. If a Dog is commanded to
speak(), this may elicit a bark(). However, if a Pig is commanded
to speak(), this may elicit an oink(). They both inherit speak()
Pg 6
from Animal, but their derived class methods override the
methods of the parent class; this is Overriding Polymorphism.
Overloading Polymorphism is the use of one method
signature, or one operator such as ‘+’, to perform several
different functions depending on the implementation. The ‘+’
operator, for example, may be used to perform integer
addition, float addition, list concatenation, or string
concatenation. Any two subclasses of Number, such as Integer
and Double, are expected to add together properly in an OOP
language. The language must therefore overload the addition
operator, ‘+’, to work this way. This helps improve code
readability. How this is implemented varies from language to
language, but most OOP languages support at least some
level of overloading polymorphism. Many OOP languages also
support Parametric Polymorphism, where code is written
without mention of any specific type and thus can be used
transparently with any number of new types. Pointers are an
example of a simple polymorphic routine that can be used
with many different types of objects.[2]
Decoupling
Decoupling allows for the separation of object interactions
from classes and inheritance into distinct layers of
abstraction. A common use of decoupling is to polymorphically
decouple the encapsulation, which is the practice of using
reusable code to prevent discrete code modules from
interacting with each other.
History
Pg 7
combinatorial explosion of how the different attributes from
different ships could affect one another. The idea occurred to group
the different types of ships into different classes of objects, each
class of objects being responsible for defining its own data and
behavior.)[citation needed] Such an approach was a simple extrapolation
of concepts earlier used in analog programming. On analog
computers, mapping from real-world phenomena/objects to analog
phenomena/objects (and conversely), was (and is) called
'simulation'. Simula not only introduced the notion of classes, but
also of instances of classes, which is probably the first explicit use
of those notions. The ideas of Simula 67 influenced many later
languages, especially Smalltalk and derivatives of Lisp and Pascal.
At ETH Zürich, Niklaus Wirth and his colleagues had also been
investigating such topics as data abstraction and modular
programming. Modula-2 included both, and their succeeding design,
Oberon, included a distinctive approach to object orientation,
Pg 8
classes, and such. The approach is unlike Smalltalk, and very unlike
C++.
In the past decade Java has emerged in wide use partially because
of its similarity to C and to C++, but perhaps more importantly
because of its implementation using a virtual machine that is
intended to run code unchanged on many different platforms. This
last feature has made it very attractive to larger development shops
with heterogeneous environments. Microsoft's .NET initiative has a
similar objective and includes/supports several new languages, or
variants of older ones with the important caveat that it is, of course,
restricted to the Microsoft platform.
Pg 9
keep track of which functions called which other functions, and what
data was changed. To make sense of this potentially confusing
situation, structured programming was created.
Pg 10
The Pillars of OOP Development
When working with computers, it is very important to be
fashionable! In the 1960s, the new fashion was what were called
high-level languages such as FORTRAN and COBOL, in which the
programmer did not have to understand the machine instructions.
In the 1970s, people realized that there were better ways to
program than with a jumble of GOTO statements, and the
structured programming languages such as COBOL were invented.
In the 1980s, much time was invested in trying to get good results
out of fourth-generation languages (4Gls), in which complicated
programming structures could be coded in a few words (if you could
find the right words with so many words to choose from). There
were also schemes such as Analyst Workbenches, which made
systems analysts into highly paid and overqualified programmers.
The fashion of the 1990s is most definitely object-oriented
programming.
Importance of OOP
Definition: Object-oriented programming is a productivity tool.
Each of these features is a step on the road to reliable and
productive programming. By using pre-built libraries of code, you
can save time and still have the flexibility of altering the way that
they work to suit your own needs. With OOP there are lots of extra
features that encourage putting thought into structuring programs
so that they are more maintainable. By gathering code into
CLASSES, large programs are divided into small manageable
sections, in the same way that you divide small programs into
functions. This is very important, because the difficulty of
understanding pieces of code increases exponentially.
Pg 11
WEEK Two
UNIFIED MODELLING LANGUAGE (UML) – The General Overview
Introduction
UML combines the best practice from data modelling concepts such
as entity relationship diagrams, business modelling (work flow),
object modelling and component modelling. It can be used with all
processes, throughout the software development life cycle, and
across different implementation technologies.
Standardization
UML is officially defined by the Object Management Group (OMG) as
the UML metamodel, a Meta-Object Facility metamodel (MOF). Like
other MOF-based specifications, UML has allowed software
developers to concentrate more on design and architecture.
UML models may be automatically transformed to other
representations (e.g. Java) by means of QVT-like transformation
languages, supported by the OMG.
History
History of Object Oriented methods and notation.
Pg 12
Before UML 1.x
After Rational Software Corporation hired James Rumbaugh from
General Electric in 1994, the company became the source for the
two most popular object-oriented modeling approaches of the day:
Rumbaugh's OMT, which was better for object-oriented analysis
(OOA), and Grady Booch's Booch method, which was better for
object-oriented design (OOD). Together Rumbaugh and Booch
attempted to reconcile their two approaches and started work on a
Unified Method.
They were soon assisted in their efforts by Ivar Jacobson, the
creator of the object-oriented software engineering (OOSE) method.
Jacobson joined Rational in 1995, after his company, Objectory, was
acquired by Rational. The three methodologists were collectively
referred to as the Three Amigos, since they were well known to
argue frequently with each other regarding methodological
preferences.
UML 1.x
As a modeling notation, the influence of the OMT notation
dominates (e. g., using rectangles for classes and objects). Though
the Booch "cloud" notation was dropped, the Booch capability to
specify lower-level design detail was embraced. The use case
notation from Objectory and the component notation from Booch
were integrated with the rest of the notation, but the semantic
integration was relatively weak in UML 1.1, and was not really fixed
until the UML 2.0 major revision.
Pg 13
Concepts from many other OO methods were also loosely integrated
with UML with the intent that UML would support all OO methods.
For example CRC Cards (circa 1989 from Kent Beck and Ward
Cunningham), and OORam were retained. Many others contributed
too with their approaches flavoring the many models of the day
including: Tony Wasserman and Peter Pircher with the "Object-
Oriented Structured Design (OOSD)" notation (not a method), Ray
Buhr's "Systems Design with Ada", Archie Bowen's use case and
timing analysis, Paul Ward's data analysis and David Harel's
"Statecharts", as the group tried to ensure broad coverage in the
real-time systems domain. As a result, UML is useful in a variety of
engineering problems, from single process, single user applications
to concurrent, distributed systems, making UML rich but large.
The Unified Modeling Language is an international standard:
Although many UML tools support some of the new features of UML
2.x, the OMG provides no test suite to objectively test compliance
with its specifications.
Methods
UML is not a method by itself; however, it was designed to be
compatible with the leading object-oriented software development
methods of its time (for example OMT, Booch method, Objectory).
Since UML has evolved, some of these methods have been recast to
take advantage of the new notations (for example OMT), and new
methods have been created based on UML. The best known is IBM
Rational Unified Process (RUP). There are many other UML-based
methods like Abstraction Method, Dynamic Systems Development
Pg 14
Method, and others, designed to provide more specific solutions, or
achieve different objectives.
Modelling
It is very important to distinguish between the UML model and the
set of diagrams of a system. A diagram is a partial graphical
representation of a system's model. The model also contains a
"semantic backplane" — documentation such as written use cases
that drive the model elements and diagrams.
UML diagrams represent three different views of a system model:
• Functional requirements view: Emphasizes the functional
requirements of the system from the user's point of view. And
includes use case diagrams.
• Static structural view: Emphasizes the static structure of the
system using objects, attributes, operations and relationships.
And includes class diagrams and composite structure
diagrams.
• Dynamic behavior view: Emphasizes the dynamic behavior of
the system by showing collaborations among objects and
changes to the internal states of objects. And includes
sequence diagrams, activity diagrams and state machine
diagrams.
UML models can be exchanged among UML tools by using the XMI
interchange format.
Diagrams overview
UML 2.0 has 13 types of diagrams divided into three categories: Six
diagram types represent structure application structure, three
represent general types of behavior, and four represent different
aspects of interactions. These diagrams can be categorized
hierarchically as shown in the following Class diagram:
Pg 15
UML does not restrict UML element types to a certain diagram type.
In general, every UML element may appear on almost all types of
diagrams. This flexibility has been partially restricted in UML 2.0.
In keeping with the tradition of engineering drawings, a comment or
note explaining usage, constraint, or intent is always allowed in a
UML diagram.
Structure diagrams
Structure diagrams emphasize what things must be in the system
being modeled:
• Class diagram: describes the structure of a system by
showing the system's classes, their attributes, and the
relationships among the classes.
• Component diagram: depicts how a software system is split
up into components and shows the dependencies among
these components.
• Composite structure diagram: describes the internal structure
of a class and the collaborations that this structure makes
possible.
• Deployment diagram serves to model the hardware used in
system implementations, the components deployed on the
hardware, and the associations among those components.
• Object diagram: shows a complete or partial view of the
structure of a modeled system at a specific time.
• Package diagram: depicts how a system is split up into logical
groupings by showing the dependencies among these
groupings.
Composite
Class diagram Component structure diagrams Deployment
diagram
diagram
Object
diagram Package
diagram
Pg 16
Behavior diagrams
Behavior diagrams emphasize what must happen in the system
being modeled:
• Activity diagram: represents the business and operational
step-by-step workflows of components in a system. An
activity diagram shows the overall flow of control.
• State diagram: standardized notation to describe many
systems, from computer programs to business processes.
• Use case diagram: shows the functionality provided by a
system in terms of actors, their goals represented as use
cases, and any dependencies among those use cases.
Interaction diagrams
Interaction diagrams, a subset of behavior diagrams, emphasize the
flow of control and data among the things in the system being
modelled:
• Communication diagram shows the interactions between
objects or parts in terms of sequenced messages. They
represent a combination of information taken from Class,
Sequence, and Use Case Diagrams describing both the static
structure and dynamic behavior of a system.
• Interaction overview diagram: a type of activity diagram in
which the nodes represent interaction diagrams.
• Sequence diagram: shows how objects communicate with
each other in terms of a sequence of messages. Also indicates
the lifespans of objects relative to those messages.
• Timing diagrams: are a specific type of interaction diagram,
where the focus is on timing constraints.
Communication
diagram Interaction overview Sequence
diagram diagram
Pg 17
The Relevance of UML to Software
People all over the world use common notations usually pictorial to
depict events, actions, operations or activities. Example is in the
fields of mathematics where signs such as +, =, - etc are common
and generally accepted arithmetic notations. With little or no
explanation everyone can easily understand what they mean.
Another mathematic example is diagram such as the one below;
Now this has a few very endearing properties. First, it is once again
an example of a universal notation. Right angles, right triangles,
and the symbols representing them are the same all over the world;
someone from ancient Egypt could in principle reason about right
triangles with a modern Peruvian by drawing such diagrams. What's
more, once the diagram for the right triangle has been written
down, the relationship of A, B, and C is defined. A, B, and C can no
longer have completely arbitrary values; once any two of them are
specified, the third is determined as well. The diagram implies the
Pythagorean Theorem. One could even go so far as to say that the
diagram has some "semantics," that there is a well-understood
relationship between the picture and the values implied by the
letters.
Pg 18
What is truly amazing about this example is that anyone with a high
school education can understand it. If the person has seen any
geometry at all, they have seen triangles and right triangles, and if
they remember anything at all from their geometry, it is good old
Pythagoras.
We can say that not only in mathematics but in all other fields
progress is made by having a common notation that can be used to
express concepts, and how diagrams begin to take on precision and
meaning once we attach semantics to the pictures. The most useful
of these notations are understood the world over.
But before 1996 there was no common notation for software. Before
the UML became an international standard, two software engineers,
even if they spoke the same language, had no way to talk about
their software. There were no conventions that were universally
accepted around the world for describing software. No wonder
progress was slow!
An electrical circuit
Pg 19
that irreversibly cast the die. Everyone agreed to end the Tower of
Babel approach and also agreed about how to talk about software.
The significance of the UML is now established, and we can move
on.
Pg 20
WEEK Three
Introduction
The structure diagrams show the static structure of the system
being modelled; focusing on the elements of a system, irrespective
of time. Static structure is conveyed by showing the types and their
instances in the system. Besides showing system types and their
instances, structure diagrams also show at least some of the
relationships among and between these elements and potentially
even show their internal structure.
Structure diagrams are useful throughout the software lifecycle for
a variety of team members. In general, these diagrams allow for
design validation and design communication between individuals
and teams. For example, business analysts can use class or object
diagrams to model a business's current assets and resources, such
as account ledgers, products, or geographic hierarchy. Architects
can use the component and deployment diagrams to test/verify that
their design is sound. Developers can use class diagrams to design
and document the system's coded (or soon-to-be-coded) classes.
Pg 21
The Class diagram describes the structure of a system by showing
the system's classes, their attributes, and the relationships among
the classes.
• a class
• an interface
• a data type
• a component.
Class name
The UML representation of a class is a rectangle containing three
compartments stacked vertically, as shown in Figure 3.1. The top
compartment shows the class's name. The middle compartment lists
the class's attributes. The bottom compartment lists the class's
operations. When drawing a class element on a class diagram, you
must use the top compartment, and the bottom two compartments
Pg 22
are optional. (The bottom two would be unnecessary on a diagram
depicting a higher level of detail in which the purpose is to show
only the relationship between the classifiers.) Figure 3.1 shows an
airline flight modelled as a UML class. As we can see, the name is
Flight, and in the middle compartment we see that the Flight class
has three attributes: flightNumber, departureTime, and
flightDuration. In the bottom compartment we see that the Flight
class has two operations: delayFlight and getArrivalTime.
flightNumber : Integer
Table 3.1: The Flight class's attribute names with their associated
types
Attribute Name Attribute Type
flightNumber Integer
departureTime Date
flightDuration Minutes
Pg 23
In business class diagrams, the attribute types usually correspond
to units that make sense to the likely readers of the diagram (i.e.,
minutes, dollars, etc.). However, a class diagram that will be used
to generate code needs classes whose attribute types are limited to
the types provided by the programming language, or types included
in the model that will also be implemented in the system.
Sometimes it is useful to show on a class diagram that a particular
attribute has a default value. (For example, in a banking account
application a new bank account would start off with a zero balance.)
The UML specification allows for the identification of default values
in the attribute list section by using the following notation:
For example:
balance : Dollars = 0
Figure 3.2: A Bank Account class diagram showing the balance attribute's
value defaulted to zero dollars.
Pg 24
Table 3.2: Flight class's operations mapped from Figure 3.2
Operation Name Parameters Return Value Type
delayFlight Name Type N/A
numberOfMinutes Minutes
getArrivalTime N/A Date
Figure 3.3 shows that the delayFlight operation has one input
parameter -- numberOfMinutes -- of the type Minutes. However, the
delayFlight operation does not have a return value. When an
operation has parameters, they are put inside the operation's
parentheses; each parameter uses the format "parameter name :
parameter type".
Figure 3.3: The Flight class operations parameters include the optional
"in" marking.
Inheritance
Pg 25
A very important concept in object-oriented design, inheritance,
refers to the ability of one class (child class) to inherit the identical
functionality of another class (super class), and then add new
functionality of its own. (In a very non-technical sense, imagine that
I inherited my mother's general musical abilities, but in my family
I'm the only one who plays electric guitar.) To model inheritance on
a class diagram, a solid line is drawn from the child class (the class
inheriting the behavior) with a closed, unfilled arrowhead (or
triangle) pointing to the super class. Consider types of bank
accounts: Figure 3.4 shows how both CheckingAccount and
SavingsAccount classes inherit from the BankAccount class.
Pg 26
Figure 3.5: An example of inheritance using tree notation
Associations
When you model a system, certain objects will be related to each
other, and these relationships themselves need to be modelled for
clarity. There are five types of associations. -- bi-directional, uni-
directional associations, Association class, Aggregation, and
Reflexive associations --
Pg 27
Figure 3.6: An example of a bi-directional association between a Flight
class and a Plane class
Pg 28
5..15 Five to Fifteen
Uni-directional association
In a uni-directional association, two classes are related, but only
one class knows that the relationship exists. Figure 3.7 shows an
example of an overdrawn accounts report with a uni-directional
association.
Association class
In modeling an association, there are times when you need to
include another class because it includes valuable information about
the relationship. For this you would use an association class that
you tie to the primary association. An association class is
represented like a normal class. The difference is that the
association line between the primary classes intersects a dotted line
connected to the association class. Figure 3.8 shows an association
class for our airline industry example.
Pg 29
Figure 3.8: Adding the association class MileageCredit
Aggregation
Aggregation is a special type of association used to model a "whole
to its parts" relationship. In basic aggregation relationships, the
lifecycle of a part class is independent from the whole class's
lifecycle.
For example, we can think of Car as a whole entity and Car Wheel
as part of the overall Car. The wheel can be created weeks ahead of
time, and it can sit in a warehouse before being placed on a car
during assembly. In this example, the Wheel class's instance clearly
lives independently of the Car class's instance. However, there are
times when the part class's lifecycle is not independent from that of
the whole class -- this is called composition aggregation. Consider,
for example, the relationship of a company to its departments. Both
Company and Departments are modelled as classes, and a
department cannot exist before a company exists. Here the
Department class's instance is dependent upon the existence of the
Company class's instance.
Let's explore basic aggregation and composition aggregation
further.
Basic aggregation
An association with an aggregation relationship indicates that one
class is a part of another class. In an aggregation relationship, the
child class instance can outlive its parent class. To represent an
aggregation relationship, you draw a solid line from the parent class
to the part class, and draw an unfilled diamond shape on the parent
class's association end. Figure 3.9 shows an example of an
aggregation relationship between a Car and a Wheel.
Pg 30
Figure 3.9: Example of an aggregation association
Composition aggregation
The composition aggregation relationship is just another form of the
aggregation relationship, but the child class's instance lifecycle is
dependent on the parent class's instance lifecycle. In Figure 3.10,
which shows a composition relationship between a Company class
and a Department class, notice that the composition relationship is
drawn like the aggregation relationship, but this time the diamond
shape is filled.
Reflexive associations
We have now discussed all the association types. As you may have
noticed, all our examples have shown a relationship between two
different classes. However, a class can also be associated with itself,
using a reflexive association. This may not make sense at first, but
remember that classes are abstractions. Figure 3.11 shows how an
Employee class could be related to itself through the
manager/manages role. When a class is associated to itself, this
does not mean that a class's instance is related to itself, but that an
instance of the class is related to another instance of the class.
Pg 31
Figure 3.11: Example of a reflexive association relationship
Pg 32
WEEK Four
Packages
Inevitably, if you are modelling a large system or a large area of a
business, there will be many different classifiers in your model.
Managing all the classes can be a daunting task; therefore, UML
provides an organizing element called a package. Packages enable
modellers to organize the model's classifiers into namespaces,
which is sort of like folders in a filing system. Dividing a system into
multiple packages makes the system easier to understand,
especially if each package represents a specific part of the system.
There are two ways of drawing packages on diagrams. There is no
rule for determining which notation to use, except to use your
personal judgement regarding which is easiest to read for the class
diagram you are drawing. Both ways begin with a large rectangle
with a smaller rectangle (tab) above its upper left corner, as seen in
Figure 3.13. But the modeller must decide how the package's
membership is to be shown, as follows:
Pg 33
Figure 3.12: An example package element that shows its members inside
the package's rectangle boundaries
Pg 34
Figure 3.13: An example package element showing its membership via
connected lines
Interfaces
Earlier in this article, it is suggested that you think of classifiers
simply as classes. In fact, a classifier is a more general concept,
which includes data types and interfaces.
So why do I mention data types and interfaces here? There are
times when you might want to model these classifier types on a
structure diagram, and it is important to use the proper notation in
doing so, or at least be aware of these classifier types. Drawing
these classifiers incorrectly will likely confuse readers of your
structure diagram, and the ensuing system will probably not meet
requirements.
Pg 35
A class and an interface differ: A class can have an actual instance
of its type, whereas an interface must have at least one class to
implement it. In UML 2, an interface is considered to be a
specialization of a class modelling element. Therefore, an interface
is drawn just like a class, but the top compartment of the rectangle
also has the text "«interface»", as shown in Figure 3.14
Visibility
In object-oriented design, there is a notation of visibility for
attributes and operations. UML identifies four types of visibility:
public, protected, private, and package.
Pg 36
The UML specification does not require attributes and operations
visibility to be displayed on the class diagram, but it does require
that it be defined for each attribute or operation. To display visibility
on the class diagram, you place the visibility mark in front of the
attribute's or operation's name. Though UML specifies four visibility
types, an actual programming language may add additional
visibilities, or it may not support the UML-defined visibilities. Table
3.4 displays the different marks for the UML-supported visibility
types.
Now, let's look at a class that shows the visibility types indicated for
its attributes and operations. In Figure 3.15, all the attributes and
operations are public, with the exception of the updateBalance
operation. The updateBalance operation is protected.
Instances
When modelling a system's structure it is sometimes useful to show
example instances of the classes. To model this, UML 2 provides the
Pg 37
instance specification element, which shows interesting information
using example (or real) instances in the system.
The notation of an instance is the same as a class, but instead of
the top compartment merely having the class's name, the name is
an underlined concatenation of:
For example:
Donald : Person
Pg 38
Figure 3.17: An example of Figure 3.6 using instances instead of classes
Figure 3.17 has two instances of the Flight class because the class
diagram indicated that the relationship between the Plane class and
the Flight class is zero-to-many. Therefore, our example shows the
two Flight instances that the NX0337 Plane instance is related to.
Roles
Modelling the instances of classes is sometimes more detailed than
one might wish. Sometimes, you may simply want to model a
class's relationship at a more generic level. In such cases, you
should use the role notation. The role notation is very similar to the
instances notation. To model a class's role, you draw a box and
place the class's role name and class name inside as with the
instances notation, but in this case you do not underline the words.
Figure 3.18 shows an example of the roles played by the Employee
class described by the diagram at Figure 3.11. In Figure 3.18, we
can tell, even though the Employee class is related to itself, that the
relationship is really between an Employee playing the role of
manager and an Employee playing the role of team member.
Note that you cannot model a class's role on a plain class diagram,
even though Figure 18 makes it appear that you can. In order to
use the role notation you will need to use the Internal Structure
notation, discussed next.
Pg 39
Internal Structures
One of the more useful features of UML 2 structure diagrams is the
new internal structure notation. It allows you to show how a class or
another classifier is internally composed. This was not possible in
UML 1.x, because the notation set limited you to showing only the
aggregation relationships that a class had. Now, in UML 2, the
internal structure notation lets you more clearly show how that
class's parts relate to each other.
Figure 3.19: A class diagram that only shows relationships between the
objects
Pg 40
Figure3. 20: An example internal structure of a Plane class.
In Figure 3.20 the Plane has two ControlSoftware objects and each
one controls two engines. The ControlSoftware on the left side of
the diagram (control1) controls engines 1 and 2. The
ControlSoftware on the right side of the diagram (control2) controls
engines 3 and 4.
Conclusion
There are at least two important reasons for understanding the
class diagram.
Developers will think the class diagram was created specially for
them; but other team members will find them useful, too.
Pg 41
WEEK Five
COMPOSITE DIAGRAM
Introduction
Part
A part is an element that represents a set of one or more instances
which are owned by a containing classifier instance. So for example,
if a diagram instance owned a set of graphical elements, then the
graphical elements could be represented as parts; if it were useful
to do so, to model some kind of relationship between them. Note
that a part can be removed from its parent before the parent is
deleted, so that the part isn't deleted at the same time.
Pg 42
Port
A port is a typed element that represents an externally visible part
of a containing classifier instance. Ports define the interaction
between a classifier and its environment. A port can appear on the
boundary of a contained part, a class or a composite structure. A
port may specify the services a classifier provides as well as the
services that it requires of its environment.
Pg 43
Interfaces
An interface is similar to a class but with a number of restrictions.
All interface operations are public and abstract, and do not provide
any default implementation. All interface attributes must be
constants. However, while a class may only inherit from a single
super-class, it may implement multiple interfaces.
Note that the circle notation does not show the interface operations.
When interfaces are shown as being owned by classes, they are
referred to as exposed interfaces. An exposed interface can be
defined as either provided or required. A provided interface is an
affirmation that the containing classifier supplies the operations
defined by the named interface element and is defined by drawing a
realization link between the class and the interface. A required
interface is a statement that the classifier is able to communicate
with some other classifier which provides operations defined by the
named interface element and is defined by drawing a dependency
link between the class and the interface.
Pg 44
Delegate
A delegate connector is used for defining the internal workings of a
component's external ports and interfaces. A delegate connector is
shown as an arrow with a «delegate» keyword. It connects an
external contract of a component as shown by its ports to the
internal realization of the behavior of the component's part.
Collaboration
A collaboration defines a set of co-operating roles used collectively
to illustrate a specific functionality. A collaboration should only show
the roles and attributes required to accomplish its defined task or
function. Isolating the primary roles is an exercise in simplifying the
structure and clarifying the behavior, and also provides for re-use. A
Pg 45
collaboration often implements a pattern.
Role Binding
A role binding connector is drawn from a collaboration to the
classifier that fulfils the role. It is shown as a dashed line with the
name of the role at the classifier end.
Represents
A represents connector may be drawn from a collaboration to a
classifier to show that a collaboration is used in the classifier. It is
shown as a dashed line with arrowhead and the keyword
«represents».
Pg 46
Occurrence
An occurrence connector may be drawn from a collaboration to a
classifier to show that a collaboration represents (sic) the classifier.
It is shown as a dashed line with arrowhead and the keyword
«occurrence».
Pg 47
WEEK Six
Introduction
The component diagram's main purpose is to show the structural
relationships between the components of a system. In UML 1.1, a
component represented implementation items, such as files and
executables. Unfortunately, this conflicted with the more common
use of the term component," which refers to things such as COM
components. Over time and across successive releases of UML, the
original UML meaning of components was mostly lost. UML 2
officially changes the essential meaning of the component concept;
in UML 2, components are considered autonomous, encapsulated
units within a system or subsystem that provide one or more
interfaces. Although the UML 2 specification does not strictly state
it, components are larger design units that represent things that will
typically be implemented using replaceable" modules. But, unlike
UML 1.x, components are now strictly logical, design-time
constructs. The idea is that you can easily reuse and/or substitute a
different component implementation in your designs because a
component encapsulates behavior and implements specified
interfaces.
Pg 48
administrators find component diagrams useful because they get an
early view of the logical software components that will be running
on their systems. Although system administrators will not be able to
identify the physical machines or the physical executables from the
diagram, a component diagram will nevertheless be welcomed
because it provides early information about the components and
their relationships (which allows sys-admins to loosely plan ahead).
The notation
The component diagram notation set now makes it one of the
easiest UML diagrams to draw. Figure 6.1 shows a simple
component diagram using the former UML 1.4 notation; the
example shows a relationship between two components: an Order
System component that uses the Inventory System component. As
you can see, a component in UML 1.4 was drawn as a rectangle
with two smaller rectangles protruding from its left side.
Figure 5.1: This simple component diagram shows the Order System's
general dependency using UML 1.4 notation
Pg 49
The basics of Component Diagram
Drawing a component in UML 2 is now very similar to drawing a
class on a class diagram. In fact, in UML 2 a component is merely a
specialized version of the class concept. Which means that the
notation rules that apply to the class classifier also apply to the
component classifier.
Pg 50
Figure 6.3: The additional compartment here shows the interfaces that
the Order component provides and requires.
Pg 51
In this second approach the interface symbols with a complete circle
at their end represent an interface that the component provides --
this lollipop" symbol is shorthand for a realization relationship of an
interface classifier. Interface symbols with only a half circle at their
end (a.k.a. sockets) represent an interface that the component
requires (in both cases, the interface's name is placed near the
interface symbol itself). Even though Figure 6.4 looks much
different from Figure 6.3, both figures provide the same information
-- i.e., the Order component provides two interfaces: OrderEntry
and AccountPayable, and the Order component requires the Person
interface.
Figure 6.5: A component diagram that shows how the Order System
component depends on other components
Figure 6.5 shows that the Order System component depends both
on the Customer Repository and Inventory System components.
Notice in Figure 6.5 the duplicated names of the interfaces
CustomerLookup" and ProductAccessor." While this may seem
unnecessarily repetitive in this example, the notation actually allows
for different interfaces (and differing names) on each component
depending on the implementation differences (e.g., one component
provides an interface that is a subclass of a smaller required
interface).
Subsystems
Pg 52
In UML 2 the subsystem classifier is a specialized version of a
component classifier. Because of this, the subsystem notation
element inherits all the same rules as the component notation
element. The only difference is that a subsystem notation element
has the keyword of subsystem" instead of component," as shown in
Figure 6.6.
Pg 53
Figure 6.7: This component's inner structure is composed of other
components.
Using the example shown in Figure 6.7, the Store component
provides the interface of OrderEntry and requires the interface of
Account. The Store component is made up of three components:
Order, Customer, and Product components. Notice how the Store's
OrderEntry and Account interface symbols have a square on the
edge of the component. This square is called a port. In a simplistic
sense, ports provide a way to model how a component's
provided/required interfaces relate to its internal parts. By using a
port, our diagram is able to de-couple the internals of the Store
component from external entities. In Figure 6.7, the OrderEntry
port delegates to the Order component's OrderEntry interface for
processing. Also, the internal Customer component's required
Account interface is delegated to the Store component's required
Account interface port. By connecting to the Account port, the
internals of the Store component (e.g. the Customer component)
can have a local representative of some unknown external entity
which implements the port's interface. The required Account
interface will be implemented by a component outside of the Store
component.
You will also notice in Figure 6.7 that the interconnections between
the inner components are different from those shown in Figure 6.5.
This is because these depictions of internal structures are really
collaboration diagrams nested inside the classifier (a component, in
our case), since collaboration diagrams show instances or roles of
classifiers. The relationship modelled between the internal
Pg 54
components is drawn with what UML calls an assembly connector."
An assembly connector ties one component's provided interface
with another component's required interface. Assembly connectors
are drawn as lollipop and socket symbols next to each other.
Drawing these assembly connectors in this manner makes the
lollipop and socket symbols very easy to read.
Conclusion
The component diagram is a very important diagram that architects
will often create early in a project. However, the component
diagram's usefulness spans the life of the system. Component
diagrams are invaluable because they model and document a
system's architecture. Because component diagrams document a
system's architecture, the developers and the eventual system
administrators of the system find this work product-critical in
helping them understand the system.
Pg 55
WEEK Seven
OBJECT AND PACKAGE DIAGRAM
Object Diagrams
Pg 56
Example Class and Object Diagrams
The following diagram shows an object diagram with its defining
class diagram inset, and it illustrates the way in which an object
diagram may be used to test the multiplicities of assignments in
class diagrams. The car class has a 1-to-many multiplicity to the
wheel class, but if a 1-to-4 multiplicity had been chosen instead,
that wouldn’t have allowed for the three-wheeled car shown in the
object diagram.
Pg 57
Package Diagrams
Pg 58
Packages are represented in UML 2.1 as folders and contain the elements
that share a namespace; all elements within a package must be
identifiable, and so have a unique name or type. The package must show
the package name and can optionally show the elements within the
package in extra compartments.
Package Merge
A «merge» connector between two packages defines an implicit
generalization between elements in the source package, and elements
with the same name in the target package. The source element definitions
are expanded to include the element definitions contained in the target.
The target element definitions are unaffected, as are the definitions of
source package elements that don't match names with any element in the
target package.
Package Import
The «import» connector indicates that the elements within the target
package, which in this example is a single class, use unqualified names
when being referred to from the source package. The source package's
namespace gains access to the target classes; the target's namespace is
not affected.
Nesting Connectors
The nesting connector between the target package and source packages
shows that the source package is fully contained in the target package.
Pg 59
WEEK Eight
DEPLOYMENT
Deployment Diagrams
Node
A Node is either a hardware or software element. It is shown as a
three-dimensional box shape, as shown below.
Node Instance
A node instance can be shown on a diagram. An instance can be
distinguished from a node by the fact that its name is underlined and has
a colon before its base node type. An instance may or may not have a
name before the colon. The following diagram shows a named instance of
a computer.
Pg 60
Node Stereotypes
A number of standard stereotypes are provided for nodes, namely
«cdrom», «cd-rom», «computer», «disk array», «pc», «pc client», «pc
server», «secure», «server», «storage», «unix server», «user pc». These
will display an appropriate icon in the top right corner of the node symbol
Artifact
An artifact is a product of the software development process. That may
include process models (e.g. use case models, design models etc), source
files, executables, design documents, test reports, prototypes, user
manuals, etc.
An artifact is denoted by a rectangle showing the artifact name, the
«artifact» keyword and a document icon, as shown below.
Pg 61
Association
In the context of a deployment diagram, an association represents a
communication path between nodes. The following diagram shows a
deployment diagram for a network, depicting network protocols as
stereotypes, and multiplicities at the association ends.
Node as Container
A node can contain other elements, such as components or artifacts. The
following diagram shows a deployment diagram for part of an embedded
system, depicting an executable artifact as being contained by the
motherboard node.
Pg 62
Pg 63
WEEK Nine
Activity Diagrams
In UML, an activity diagram is used to display the sequence of activities.
Activity diagrams show the workflow from a start point to the finish point
detailing the many decision paths that exist in the progression of events
contained in the activity. They may be used to detail situations where
parallel processing may occur in the execution of some activities. Activity
diagrams are useful for business modelling where they are used for
detailing the processes involved in business activities.
Pg 64
An Example of an activity diagram is shown below.
Activities
An activity is the specification of a parameterized sequence of behaviour.
An activity is shown as a round-cornered rectangle enclosing all the
actions, control flows and other elements that make up the activity.
Pg 65
Actions
An action represents a single step within an activity. Actions are denoted
by round-cornered rectangles.
Action Constraints
Constraints can be attached to an action. The following diagram shows an
action with local pre- and post-conditions.
Control Flow
A control flow shows the flow of control from one action to the next. Its
notation is a line with an arrowhead.
Pg 66
Initial Node
An initial or start node is depicted by a large black spot, as shown below.
Final Node
There are two types of final node: activity and flow final nodes. The
activity final node is depicted as a circle with a dot inside.
Pg 67
The difference between the two node types is that the flow final
node denotes the end of a single control flow; the activity final node
denotes the end of all control flows within the activity.
Pg 68
Decision and Merge Nodes
Decision nodes and merge nodes have the same notation: a
diamond shape. They can both be named. The control flows coming
away from a decision node will have guard conditions which will
allow control to flow if the guard condition is met. The following
diagram shows use of a decision node and a merge node.
Pg 69
A join is different from a merge in that the join synchronizes two
inflows and produces a single outflow. The outflow from a join
cannot execute until all inflows have been received. A merge passes
any control flows straight through it. If two or more inflows are
received by a merge symbol, the action pointed to by its outflow is
executed two or more times.
Expansion Region
An expansion region is a structured activity region that executes
multiple times. Input and output expansion nodes are drawn as a
group of three boxes representing a multiple selection of items. The
keyword "iterative", "parallel" or "stream" is shown in the top left
corner of the region.
Exception Handlers
Exception Handlers can be modelled on activity diagrams as in the
example below.
Pg 70
Interruptible Activity Region
An interruptible activity region surrounds a group of actions that
can be interrupted. In the very simple example below, the "Process
Order" action will execute until completion, when it will pass control
to the "Close Order" action, unless a "Cancel Request" interrupt is
received, which will pass control to the "Cancel Order" action.
Partition
An activity partition is shown as either a horizontal or vertical
swimlane. In the following diagram, the partitions are used to
separate actions within an activity into those performed by the
accounting department and those performed by the customer.
Pg 71
Pg 72
WEEK Ten
THE USE CASE MODEL
The use case model captures the requirements of a system. Use
cases are a means of communicating with users and other
stakeholders what the system is intended to do.
Pg 73
Actors can generalize other actors as detailed in the following
diagram:
Use Cases
A use case is a single unit of meaningful work. It provides a high-level
view of behavior observable to someone or something outside the system.
The notation for a use case is an ellipse.
Pg 74
The uses connector can optionally have multiplicity values at each
end, as in the following diagram, which shows a customer may only
have one withdrawal session at a time, but a bank may have any
number of customers making withdrawals concurrently.
Requirements
The requirements define the formal functional requirements that a use
case must supply to the end user. They correspond to the functional
specifications found in structured methodologies. A requirement is a
contract or promise that the use case will perform an action or provide
some value to the system.
Pg 75
Constraints
A constraint is a condition or restriction that a use case operates under
and includes pre-, post- and invariant conditions. A precondition specifies
the conditions that need to be met before the use case can proceed. A
post-condition is used to document the change in conditions that must be
true after the execution of the use case. An invariant condition specifies
the conditions that are true throughout the execution of the use case.
Scenarios
A Scenario is a formal description of the flow of events that occur during
the execution of a use case instance. It defines the specific sequence of
events between the system and the external actors. It is normally
described in text and corresponds to the textual representation of the
sequence diagram.
Pg 76
Extension Points
The point at which an extending use case is added can be defined
by means of an extension point.
System Boundary
It is usual to display use cases as being inside the system and
actors as being outside the system.
Pg 77
Pg 78
WEEK Eleven
THE STATE MACHINE MODEL
A state machine diagram models the behaviour of a single object,
specifying the sequence of events that an object goes through
during its lifetime in response to events.
States
A state is denoted by a round-cornered rectangle with the name of
the state written inside it.
Pg 79
Initial and Final States
The initial state is denoted by a filled black circle and may be
labelled with a name. The final state is denoted by a circle with a
dot inside and may also be labelled with a name.
Transitions
Transitions from one state to the next are denoted by lines with
arrowheads. A transition may have a trigger, a guard and an effect,
as below.
Pg 80
State Actions
In the transition example above, an effect was associated with the
transition. If the target state had many transitions arriving at it, and
each transition had the same effect associated with it, it would be
better to associate the effect with the target state rather than the
transitions. This can be done by defining an entry action for the
state. The diagram below shows a state with an entry action and an
exit action.
Self-Transitions
A state can have a transition that returns to itself, as in the
following diagram. This is most useful when an effect is associated
with the transition.
Pg 81
Compound States
A state machine diagram may include sub-machine diagrams, as in
the example below.
Pg 82
The notation in the above version indicates that the details of the
Check PIN sub-machine are shown in a separate diagram.
Entry Point
Sometimes you won’t want to enter a sub-machine at the normal
initial state. For example, in the following sub-machine it would be
normal to begin in the "Initializing" state, but if for some reason it
wasn’t necessary to perform the initialization, it would be possible
to begin in the "Ready" state by transitioning to the named entry
point.
Pg 83
The following diagram shows the state machine one level up.
Exit Point
In a similar manner to entry points, it is possible to have named
alternative exit points. The following diagram gives an example
where the state executed after the main processing state depends
on which route is used to transition out of the state.
Pg 84
Choice Pseudo-State
A choice pseudo-state is shown as a diamond with one transition
arriving and two or more transitions leaving. The following diagram
shows that whichever state is arrived at, after the choice pseudo-
state, is dependent on the message format selected during
execution of the previous state.
Junction Pseudo-State
Junction pseudo-states are used to chain together multiple
Pg 85
transitions. A single junction can have one or more incoming, and
one or more outgoing, transitions; a guard can be applied to each
transition. Junctions are semantic-free. A junction which splits an
incoming transition into multiple outgoing transitions realizes a
static conditional branch, as opposed to a choice pseudo-state
which realizes a dynamic conditional branch.
Terminate Pseudo-State
Entering a terminate pseudo-state indicates that the lifeline of the
state machine has ended. A terminate pseudo-state is notated as a
cross.
History States
A history state is used to remember the previous state of a state
Pg 86
machine when it was interrupted. The following diagram illustrates
the use of history states. The example is a state machine belonging
to a washing machine.
Concurrent Regions
A state may be divided into regions containing sub-states that exist
and execute concurrently. The example below shows that within the
state "Applying Brakes", the front and rear brakes will be operating
simultaneously and independently. Notice the use of fork and join
pseudo-states, rather than choice and merge pseudo-states. These
symbols are used to synchronize the concurrent threads.
Pg 87
Pg 88
WEEK Twelve
THE INTERACTION DIAGRAM
Communication Diagrams
A communication diagram, formerly called a collaboration diagram, is an
interaction diagram that shows similar information to sequence diagrams
but its primary focus is on object relationships.
Pg 89
Pg 90
SEQUENCE DIAGRAMS
A sequence diagram is a form of interaction diagram which shows objects
as lifelines running down the page, with their interactions over time
represented as messages drawn as arrows from the source lifeline to the
target lifeline.
The sequence diagram is used primarily to show the interactions between objects in
the sequential order that those interactions occur. Much like the class diagram,
developers typically think sequence diagrams were meant exclusively for them.
However, an organization's business staff can find sequence diagrams useful to
communicate how the business currently works by showing how various business
objects interact. Besides documenting an organization's current affairs, a business-
level sequence diagram can be used as a requirements document to communicate
requirements for a future system implementation. During the requirements phase of a
project, analysts can take use cases to the next level by providing a more formal level
of refinement. When that occurs, use cases are often refined into one or more
sequence diagrams.
Lifelines
A lifeline represents an individual participant in a sequence diagram. A
lifeline will usually have a rectangle containing its object name. If its name
is "self", that indicates that the lifeline represents the classifier which
owns the sequence diagram.
Pg 91
Sometimes a sequence diagram will have a lifeline with an actor
element symbol at its head. This will usually be the case if the
sequence diagram is owned by a use case. Boundary, control and
entity elements from robustness diagrams can also own lifelines.
Messages
Messages are displayed as arrows. Messages can be complete, lost or
found; synchronous or asynchronous; call or signal. In the following
diagram, the first message is a synchronous message (denoted by the
solid arrowhead) complete with an implicit return message; the second
message is asynchronous (denoted by line arrowhead), and the third is
the asynchronous return message (denoted by the dashed line).
Pg 92
Execution Occurrence
A thin rectangle running down the lifeline denotes the execution
occurrence, or activation of a focus of control. In the previous diagram,
there are three execution occurrences. The first is the source object
sending two messages and receiving two replies; the second is the target
object receiving a synchronous message and returning a reply; and the
third is the target object receiving an asynchronous message and
returning a reply.
Self Message
A self message can represent a recursive call of an operation, or one
method calling another method belonging to the same object. It is shown
as creating a nested focus of control in the lifeline’s execution occurrence.
Pg 93
Lost and Found Messages
Lost messages are those that are either sent but do not arrive at the
intended recipient, or which go to a recipient not shown on the current
diagram. Found messages are those that arrive from an unknown sender,
or from a sender not shown on the current diagram. They are denoted
going to or coming from an endpoint element.
Pg 94
by a sequence diagram. In the latter case, the lifeline is terminated by a
stop symbol, represented as a cross. In the former case, the symbol at
the head of the lifeline is shown at a lower level down the page than the
symbol of the object that caused the creation. The following diagram
shows an object being created and destroyed.
Pg 95
Combined Fragments
It was stated earlier that sequence diagrams are not intended for showing
complex procedural logic. While this is the case, there are a number of
mechanisms that do allow for adding a degree of procedural logic to
diagrams and which come under the heading of combined fragments. A
combined fragment is one or more processing sequence enclosed in a
frame and executed under specific named circumstances. The fragments
available are:
Pg 96
• Strict sequencing fragment (denoted “strict”) encloses a
series of messages which must be processed in the given
order.
• Negative fragment (denoted “neg”) encloses an invalid series
of messages.
• Critical fragment encloses a critical section.
• Ignore fragment declares a message or message to be of no
interest if it appears in the current context.
• Consider fragment is in effect the opposite of the ignore
fragment: any message not included in the consider fragment
should be ignored.
• Assertion fragment (denoted “assert”) designates that any
sequence not shown as an operand of the assertion is invalid.
• Loop fragment encloses a series of messages which are
repeated.
Pg 97
There is also an interaction occurrence, which is similar to a
combined fragment. An interaction occurrence is a reference to
another diagram which has the word "ref" in the top left corner of
the frame, and has the name of the referenced diagram shown in
the middle of the frame.
Gate
A gate is a connection point for connecting a message inside a fragment
with a message outside a fragment. EA shows a gate as a small square on
a fragment frame. Diagram gates act as off-page connectors for sequence
diagrams, representing the source of incoming messages or the target of
outgoing messages. The following two diagrams show how they might be
used in practice. Note that the gate on the top level diagram is the point
at which the message arrowhead touches the reference fragment - there
is no need to render it as a box shape.
Pg 98
Part Decomposition
An object can have more than one lifeline coming from it. This allows for
inter- and intra-object messages to be displayed on the same diagram.
Pg 99
State Invariant / Continuations
A state invariant is a constraint placed on a lifeline that must be true at
run-time. It is shown as a rectangle with semi-circular ends.
Pg 100
WEEK Thirteen
Interaction Occurrence
Interaction occurrences are references to existing interaction
diagrams. An interaction occurrence is shown as a reference frame;
that is, a frame with "ref" in the top-left corner. The name of the
diagram being referenced is shown in the center of the frame.
Interaction Element
Interaction elements are similar to interaction occurrences, in that
they display a representation of existing interaction diagrams within
a rectangular frame. They differ in that they display the contents of
the references diagram inline.
Pg 101
Putting it all Together
All the same controls from activity diagrams (fork, join, merge,
etc.) can be used on interaction overview diagrams to put the
control logic around the lower level diagrams. The following
example depicts a sample sale process, with sub-processes
abstracted within interaction occurrences.
Pg 102
Pg 103
THE TIMING DIAGRAM
State Lifeline
A state lifeline shows the change of state of an item over time. The
X-axis displays elapsed time in whatever units are chosen, while the
Y-axis is labelled with a given list of states. A state lifeline is shown
below.
Value Lifeline
A value lifeline shows the change of value of an item over time. The X-
axis displays elapsed time in whatever units are chosen, the same as for
the state lifeline. The value is shown between the pair of horizontal lines
which cross over at each change in value. A value lifeline is shown below.
Pg 104
Putting it all Together
State and value Lifelines can be stacked one on top of another in any
combination. They must have the same X-axis. Messages can be passed
from one lifeline to another. Each state or value transition can have a
defined event, a time constraint which indicates when an event must
occur, and a duration constraint which indicates how long a state or value
must be in effect for. Once these have all been applied, a timing diagram
may look like the following.
Pg 105
WEEK Fourteen
THE UML TOOLS
Introduction
So far we have defined and gained an overview of what the Unified
Modelling Language stands for and what all the diagrams that make
up UML mean. Because UML is essentially a set of diagrams, you
can simply draw them by hand on a piece of paper. But, drawing
UML diagrams on a piece of paper is certainly not a best practice to
design systems. Software applications simplify the task of drawing
diagrams of software designs. In addition, because the design is in
an electronic format, archiving the design for future use,
collaborating on the design becomes much easier. Also, routine
tasks can be automated by using a UML tool. Hence, using a UML
tool is by far the most preferred way for designing software
applications.
Pg 106
activity, state, and collaboration diagrams and the component
and deployment diagrams that form the implementation view
of the system.
Pg 107
process. Apart from a few syntax and semantic ground rules,
there are no other rules. The thought process of a software
architect who designs applications using UML can be lost if the
reasons behind certain design decisions are not captured and
well documented. This becomes painfully clear when large
systems are maintained and no one has a clue to why a
subsystem was designed in a certain way. Hence, a UML tool
must necessarily provide some way for the designer to
document design decisions in the diagrams by using simple
things such as annotations or comments. In addition to this,
the UML tool should support the generation of reports/listings
of the different design elements of the diagram.
Apart from the above features, you should also identify a few
features that would definitely be useful to have in the UML
tool.
Pg 108
• Test script generation: The system or subsystem designed
in a UML tool may represent a set of functional aspects as
well. Hence, it would be really useful if, in addition to
generating stub code, the tool also generates test scripts that
can be used for testing how the generated class functions.
Template-driven modelling
Re-usability is the key to improving productivity. An application
design may consist of several classes with relationships defined.
Quite a few times, while designing applications, you encounter the
same design problems or scenarios and end up defining the same
design again and again. By using a modelling tool, you can define
certain components or even subsystems that might potentially be
reusable in the future. For example, design elements of an
application used to define access to the database using, say, a
ConnectionPool class are potentially reusable. You might need to
define a similar database connection pool in another application as
well. Hence, it would benefit us in the long run if we design the
ConnectionPool class separately. We then can include the
ConnectionPool design in any future subsystems and avoid the need
of reinventing the wheel.
Such reusable designs or models are termed as templates and the
entire modeling process involving the identification and use of
templates is called template-driven modeling. The benefits of
template-driven modeling are apparent in the savings in design
time. You can consider model templates to be very similar to
reusable code libraries used in application development.
Pg 109
Rational Software Corporation. Rational Rose (the Rose stands
for "Rational Object-oriented Software Engineering") is a
visual modelling tool for UML. It comes in different versions
suited to different requirements. Rational Rose provides
support for all the standard features that we discussed in the
previous section such as UML diagram support, forward and
reverse engineering support, and documentation and round-
trip engineering support. Apart from this, Rational Rose also
provides support for version control, IDE integration, design
pattern modelling, test script generation, and collaborative
modelling environment. In addition, Rational Rose also
supports the designing of data models within the same
environment. An interesting feature of Rational Rose is the
ability to publish the UML diagrams as a set of Web pages and
images. This enables you to share and distribute your
application design where the Rational Rose tool is not
installed.
Pg 110
Integration of UML Tools with Integrated Development
Environments (IDEs)
One interesting feature in UML tools that we discussed in the
previous section was round-trip engineering. For round-trip
engineering to be useful, we need to have the UML tool to be used
in conjunction with an IDE. This integration of a UML tool with the
IDE will help you to really benefit from round-trip engineering. Any
changes in the application code that you make in the IDE are
immediately reflected in the model in the UML tool and vice versa.
For our discussion, we will be considering IDEs for the Java
language.
Quite a few of the UML tools on the market can be integrated with
the popular IDEs such as IBM's WebSphere Studio, Borland's
JBuilder, WebGain's Visual Café, or Sun's Forte. For instance,
Rational Rose (Java edition) provides integration with all of these
popular IDEs. Together Control Center has a special version that
integrates with IBM's WebSphere Studio.
The downside of UML tool integration is that the integration solution
is proprietary to the UML tool vendor. Hence, you might not always
find a UML tool providing integration with popular IDEs in the
market. But all this is changing. (See box for details on the Eclipse
project.)
Eclipse
Eclipse is an open source effort that has tool integration as the
long-term goal. The interesting aspect of Eclipse is that the effort is
supported by major tool vendors. Eclipse aims to define across-the-
board integration standards that will enable vendors of different
tools to seamlessly work together and provide a cohesive and single
development environment. The beauty of Eclipse is that the
integration between tools is not a proprietary solution. In layman's
terms this means that, for example, you can buy an off-the-shelf
UML tool and integrate it into your development environment
without having to worry that you might be stuck with a particular
vendor or group of vendors. Eclipse is definitely an area to watch
out for in the near future! (www.eclipse.org)
Pg 111
WEEK Fourteen
CASE TOOL APPLICATION
The Altova UModel (2008)
UModel® 2008 Enterprise Edition is an affordable UML modeling
application with a rich visual interface and superior usability
features to help level the UML learning curve, and includes many
high-end functions to empower users with the most practical
aspects of the UML 2.1.2 specification. UModel is a 32-bit Windows
application that runs on Windows 2000 / 2003, Windows XP and
Windows Vista.
Pg 112
The UModel Interface
UModel has a simplified development interface that present a
beginner in UML with a well streamlined way for achieving results.
Introducing UModel
The UML is a complete modeling language but does not discuss, or
prescribe, the methodology for the development, code generation
and round-trip engineering processes. UModel has therefore been
designed to allow complete flexibility during the modeling process:
Pg 113
customizable. Customizations are automatically recognized
during code generation.
Support for Visual Basic .NET 9.0 and C# 3.0 as well as Visual
Pg 114
Studio .NET 2008, Java 1.6
The 2008 version of UModel includes the following major and minor
enhancements:
Pg 115
ReceiveOperationEvent, SendOperationEvent and ChangeEvent.
Sequence diagrams:
Automatic generation of (syntactically correct) replies when
adding messages to sequence diagrams.
Pg 116