Professional Documents
Culture Documents
OBJECT ORIENTED
MODELLING AND DESIGN
Unified Modeling Language
• The main purpose of UML is to
– support communication about the analysis and
design of the system being developed
– support the movement from the problem domain in
the "world" to the solution domain in the machine
• two views of the same system
– one view has diagrams
– source code is another view
• UML
– graphical notation to describe software design
– has rules on how to draw models of
• classes
• associations between classes
• message sends between objects
– has become the de facto industry standard
• Not official, but everyone uses it
– Like a blueprint to show what is going on during
analysis, design and implementation
• Some Projects require UML documentation
The UML is a language for
visualizing
specifying
constructing
documenting
Models and multiple Views
Behavioral
Structural
behavioral features of a system / business process
• Communication
(collaboration)
• Sequence
• Interaction overview
• Timing 5
Diagram Taxonomy
• Structural Diagrams
show the static structure of elements in the system.
depict such things as
• the architectural organization of the system,
• the physical elements of the system,
• its runtime configuration, and
• domain-specific elements of your business,
• structure diagrams include
o Package diagram
o Class diagram
o Component diagram
o Deployment diagram
o Object diagram
o Composite structure diagram
Behavior Diagrams
• we express the dynamic behavioral semantics of a
problem or its implementation
• Behavioral diagrams are-
■ Use case diagram
■ Activity diagram
■ State machine diagram
■ Interaction diagrams
■ Sequence diagram
■ Communication diagram
■ Interaction overview diagram
■ Timing diagram
Use of diagrams in Practice
• Helps in analysis and design
• Helps in forward and reverse engineering
• Use of CASE tools
• Notations captures architecture and behavior
Conceptual, Logical and Physical
Models
• Conceptual model captures in terms of domain
and associations
• Logical models determine system architecture
and design
• Physical model describes software and
hardware composition and implementation
Role of tools
• Larger applications use automated tools
• Tools provide consistency checking, completeness,
constraint checking
• Helps developers to walk through analysis and
design
Outline:
• Introduction.
• Package.
• What is Packageable Element?
• Relationship between Packages.
• Element Import.
• Package Import.
• Package Merge.
• Package Model.
• Use-case package Diagram.
• Class Package Diagram.
• References.
• Question ?????????
Package Diagram:
54
Component Diagram – another example
55
Component Diagram – another example
(www.cs.tut.fi/tapahtumat/olio2004/richardson.pdf)
56
Component Diagram UML2.0 – architectural view
Explicit description of interfaces: lollipop
provided services to other components Component
requested services from other components
socket
An interface is a collection of 1..* methods, and 0..* attributes
Interfaces can consist of synchronous and / or asynchronous operations
A port (square) is an interaction point between the component and its environment.
Can be named; Can support uni-directional (either provide or require) or bi-directional (both provide and require)
communication; Can support multiple interfaces.
possibly concurrent interactions
fully isolate an object’s internals from its environment
caller or callee?
security AccessControl
StudentAdministration
Student Encription
Incoming
Persistence
signals/calls Outgoing
signals/calls 57
StudentSchedule DataAccess
Data[1..*]
Component Diagram: UML 1.x and UML 2.0
58
The Component Notation
The Component Diagram
Component Interfaces
Component Realization
A Component’s Internal Structure
Component diagram of ATM system
Deployment Diagram
• Introduction.
• What is Deployment Diagram?
• Relationships Deployment Diagram
• Example
Deployment Diagram
• show the structure of the run-time system
• capture the hardware that will be used to
implement the system and the links between
different items of hardware.
• Model physical hardware elements and the
communication paths between them
• Plan the architecture of a system
• Document the deployment of software
components or nodes
The Notation
Structural Diagrams - Deployment Diagram
()
71
Is this better?
More concrete
Implementation-oriented
72
Deployment Diagram of ATM system
Class Diagrams
• Introduction
• What are classes
• Notation of Classes
• Object Diagram
• Relationships of classes
• Constraints
A class describes a group of objects with
similar properties (attributes),
common behaviour (operations),
common relationships to other objects,
and common meaning (“semantics”).
Examples
Employee: has a name, employee# and department; an employee is hired, and fired; an
employee works in one or more projects
Employee
name Name (mandatory)
Attributes
(optional) employee#
department
hire()
fire() Operations
assignproject() (optional)
75
Classes
A class is a description of a set of
objects that share the same attributes,
ClassName operations, relationships, and semantics.
attributes
operations
Person
Person
Person
name : String
address : Address
birthdate : Date
ssn : Id
Operation
name Return value
Parameters
82
Object Diagram
The instances of a class are called objects.
The relation between an Object and its Class is called “Instantiation”
Two different objects may have identical attribute values (like two people with
identical name and address)
c:Company
d1:Department d2:Department
name:"Sales" name:"R&D"
link
d3:Department
object
name:"US Sales" attribute value
anonymous object
p:Person :ContactInformation
name:"Erin" address="1472 Miller St."
employeeID=4362
title="VP of Sales"
The name of an object may be written in any of the three following
forms:
■ objectName Object name only
■ :ClassName Object class only
■ objectName :ClassName Object name and class
Object Relationship
Class diagrams show classes and their relationships
In UML, there are different types of relationships:
Association
Aggregation and Composition
Generalization
Dependency
87
Associations are semantic connections between
classes.
Ifthere is a link between two objects, there must be an
association between the classes of those objects.
Links are instances of associations just as objects are
instances of classes.
Association
Link
88
Associations may optionally have the following properties:
Association name
may be prefixed or post fixed with a small black arrowhead to indicate the direction in which the
name should be read;
should be a verb or verb phrase;
Role names
on one or both association ends;
should be a noun or noun phrase describing the semantics of the role;
Multiplicity
The number of objects that can participate in an instantiated relation
Navigability
* *
multiplicity multiplicity
89
Ask questions about the associations:
Can a company exist without any employee?
If yes, then the association is optional at the Employee end - zero or more (0..*)
If no, then it is not optional - one or more (1..*)
If it must have only one employee - exactly one (1)
What about the other end of the association?
Can an employee work for more than one company?
No. So the correct multiplicity is one.
1 0 .. *
Company Employee
90
91
Association Relationships (Cont’d)
Associations can also be objects themselves, called link classes or an
association classes.
Registration
modelNumber
serialNumber
warrentyCode
Product Warranty
0..* employer
Job
next
description : string
employee 1..* dateHired : Date
LinkedListNode
salary : Money previous
Person
1 1
Bank Account number Person
has
2/14/05 G-94
Generalization
• Generalization is a relationship between a
more general thing and a more specific thing:
Parent
More general element
Superclass
Ancestor
Base Class
{ kind of}
Child
Subclass
Descendant
More specific element
Leaf
Inheritance
Class inheritance is implicit in a generalization relationship between
classes.
Subclasses inherit attributes, associations, & operations from the
superclass
Notes:
A subclass may override an inherited aspect
e.g. AdminStaff & CreativeStaff have different methods for calculating bonuses
A Subclass may add new features
qualification is a new attribute in CreativeStaff
Superclasses may be declared {abstract}, meaning they have no instances
Implies that the subclasses cover all possibilities
e.g. there are no other staff than AdminStaff and CreativeStaff
Aggregation
This is the “Has-a” or “Whole/part” relationship
aggregation
Club Member
* *
1 Has 1 Engine
Car Makes
Transmission
1 1
99
Aggregation
This is the “Has-a” or “Whole/part” relationship
Composition
Strong form of aggregation that implies ownership:
if the whole is removed from the model, so is the part.
the whole is responsible for the disposition of its parts
Note: Parts can be removed from the composite (where allowed) before the composite is
deleted
Scrollbar
1 1
Window Titlebar
1 1
Menu
1 1 .. *
composition
:Locomotive 1..*
1 0..1
:Car :Train
0..1 0..1
:Person 0..*
driver 1 passengers
aggregation
102
Dependency Relationships
A dependency indicates a semantic relationship between two or
more elements. The dependency from CourseSchedule to Course exists because
Course is used in both the add and remove operations of CourseSchedule.
CourseSchedule
Course
add(c : Course)
remove(c : Course)
• Recommendation: Use
sparingly!
Person
• This example: from UML
gender : {female, male}
User Guide, p. 82
husband 0..1 0..1 wife
2/14/05 G-104
Constraints on links
• Example from UML User
Guide, p. 88 Department
• A dependency and a
constraint used * *
• Shows Manager must be one
of Members of a {subset}
Department
• One link (say, Jane-to-DeptA) member 1..* manager 1
is a subset of all links
between Persons and DeptA Person
2/14/05 G-105
Class Activity
• Draw the UML class diagram which represents
a ATM system and Ticket Sales
Example: Ticket Sales
2/14/05 G-108
Composite structure diagrams
• Introduction
• Syntax
• Example
Introduction
• UML Composite structure diagrams are used
to explore run-time instances of
interconnected instances collaborating over
communications links.
• Show the internal structure (including parts
and connectors) of a structured classifier or
collaboration.
110
Syntax of a composite structure
Diagram
• Composite Structure Diagrams show the internal parts of a class.
Parts are named:
partName:partType[multiplicity]
Composite structure Diagram of ATM system
Interaction Diagrams
• Use case Diagrams
• Sequence Diagrams
• Activity Diagrams
Interaction Diagrams
• Interaction diagrams model the behavior of use cases by
describing the way groups of objects interact to complete the
task.
When to Use: Interaction Diagrams
• Interaction diagrams are used when you want to model the
behavior of several objects in a use case. They demonstrate
how the objects collaborate for the behavior. Interaction
diagrams do not give a in depth representation of the
behavior.
Use Case Diagram
• What is a Use Case
• Use Cases Diagram
• Use Case - Relationships
– Generalization
– Association
– Include
– Extends
Make
Appointment
Use Cases Diagram
• Use case diagrams describe what a system
does from the standpoint of an external
observer. The emphasis is on what a system
does rather than how.
• Relationships
– Represent communication between actor and use
case
– Depicted by line or double-headed arrow line
– Also called association relationship
Make
Appointment
Use Case - Relationships
• Boundary
– A boundary rectangle is placed around the perimeter
of the system to show how the actors communicate
with the system.
Make
Appointment
The picture below is a Make Appointment use case for the
medical clinic.
The actor is a Patient. The connection between actor and use
case is a communication association (or communication for
short).
Use-Case Diagram
Generalization
Include
Extend
Components of Use Case Diagram
• Generalization Relationship
– Represented by a line and a hollow arrow
• From child to parent
• Include Relationship
– Represents the inclusion of the functionality of one
use case within another
– Arrow is drawn from the base use case to the used
use case
– Write << include >> above arrowhead line
Use Case Diagram
• Extend relationship
– Represents the extension of the use case to
include optional functionality
– Arrow is drawn from the extension use case to the
base use case
– Write << extend >> above arrowhead line
Example of Relationships
Use Case Specification
Use case name: Maintain Storage Tanks
Use case purpose: This use case provides the ability to maintain the fill
levels of the contents of the storage tanks. This use case allows the actor to
maintain specific sets of water and nutrient tanks.
Optimistic flow:
A. Actor examines the levels of the storage tanks’ contents.
B. Actor determines that tanks need to be refilled.
C. Normal hydroponics system operation of storage tanks is suspended by
the actor.
D. Actor selects tanks and sets fill levels.
For each selected tank, steps E through G are performed.
E. If tank is heated, the system disables heaters.
1. Heaters reach safe temperature.
F. The system fills tank.
G. When tank is filled, if tank is heated, the system enables heaters.
1. Tank contents reach operating temperature.
H. Actor resumes normal hydroponics system operation.
Pragmatic flows:
Conditions triggering alternate flow:
Condition 1: There is insufficient material to fill tanks to the levels
specified by the actor.
D1. Alert actor regarding insufficient material available to meet tank
setting. Show amount of material available.
D2. Prompt actor to choose to end maintenance or reset fill levels.
D3. If reset chosen, perform step D.
D4. If end maintenance chosen, perform step H.
D5. Else, perform step D2.
Condition 2: . . .
Benefits of Use Cases
• Use cases are the primary vehicle for requirements capture.
• Use cases are described using the language of the customer
(language of the domain which is defined in the glossary)
• Use cases provide a contractual delivery process (RUP is Use
Case Driven)
• Use cases provide an easily-understood communication
mechanism
• When requirements are traced, they make it difficult for
requirements to fall through the cracks
• Use cases provide a concise summary of what the system
should do at an abstract (low modification cost) level.
Sequence Diagram
• Communication Diagram
• Scenarios
• Benefits of scenarios
• Sequence Diagram
• Types of Messages
• Procedural Sequence Models
• Sequence Diagrams with Transient Objects
Communication diagram
• Communication diagrams used to model the
dynamic behavior of the use case. When
compare to Sequence Diagram, the
Communication Diagram is more focused on
showing the collaboration of objects rather
than the time sequence.
Communication diagram
Scenarios
• A scenario is a sequence of events that occurs during one
particular execution of a system.
• For example:
John Doe logs in transmits a message from John Doe to the
broker system.
Benefits of scenarios
:Name Object
Life line
Activation
146
Sequence Diagram – Time & Messages
• Messages are used to illustrate communication between
different active objects of a sequence diagram.
:Name1 :Name2
Actor
Message One
Message Two
147
Types of Messages
• Synchronous (flow interrupt until the message has
completed.
148
Sequence diagram
Procedural Sequence Models
• Sequence Diagrams with Passive Objects
• A passive object is not activated until it has been called.
Sequence Diagrams with Transient Objects
Timing diagram
• Timing diagram shows the behavior of the
objects in a given period of time.
• Timing diagram is a special form of a sequence
diagram. The differences between timing
diagram and sequence diagram are the axes
are reversed so that the time are increase
from left to right and the lifelines are shown in
separate compartments arranged vertically.
Timing constraints
Useful in real-time applications
useful to specify race condition behaviour
Two ways to specify (in 1.x)
156
Activity Diagrams
• Introduction
• Special constructs for activity diagrams
Introduction
•An activity diagram shows the
sequence of steps that make up a
complex process, such as an
algorithm or workflow.
•Activity diagrams are most useful
during the early stages of designing
algorithms and workflows.
•Activity diagram is like a traditional
flowchart in that it shows the flow of
control from step to step.
Activity Diagram for ATM
card transaction
Special constructs for activity
diagrams
• Sending and receiving signals
• Swim lanes
• Object flows
Activity Diagram Basics
• Activity Diagram – a special kind of Statechart diagram, but showing the flow from activity to activity (not
from state to state).
• Activity state –non-atomic execution, ultimately result in some action; a composite made up of other
activity/action states; can be represented by other activity diagrams
• Action state –atomic execution, results in a change in state of the system or the return of a value (i.e.,
calling another operation, sending a signal, creating or destroying an object, or some computation); non-
decomposable
No notational distinction between
initial state action and activity states!
optional
Select site But, activity states can have certain
triggerless transition types of parts
action state do construct()
Commission
architect Entry/ setLock()
Finish : CertificateOfOccupancy
final state construction [completed]
0..* 162
Swimlanes & Object Flow
• A swimlane is a kind of package.
• Every activity belongs to exactly one swimlane, but transitions may cross lanes.
• Object flow – objects connected using a dependency to the activity or transition that
creates, destroys, or modifies them
Collect order
flow final
the process stops at this point for this
part of the activity diagram
On First up floor
Moving
arrive at Floor Up
first floor
Moving to
An Elevator up floor
First Floor arrive at
floor
arrive at floor
Idle
Moving
Down down floor
time-out
State chart Diagrams
A State chart diagram shows the lifecycle of an object
• A state is a condition of an object for a particular time
• An event causes a transition from one state to another state
• Here is a State chart for a Phone Line object:
state
initial State
event
transition
Conditions
• Used as guards on transitions.
– A guarded transition only fires when the condition
is true e.g.
• When you go out in the morning (event),
• If the temperature is below freezing (condition).
• Put on your gloves (next state).
State Transition Diagram With
Conditions
Traffic light