SlideShare a Scribd company logo
1 of 57
Chapter 2
Modeling with UML
1
Overview: modeling with UML
❖ What is modeling?
❖ What is UML?
❖ Use case diagrams
❖ Class diagrams
❖ Sequence diagrams
❖ Activity diagrams
What is modeling?
❖ Modeling consists of building an abstraction of
reality.
❖ Abstractions are simplifications because:
▪ They ignore irrelevant details and
▪ They only represent the relevant details.
❖ What is relevant or irrelevant depends on the
purpose of the model.
Example: street map
Why model software?
Why model software?
❖ Software is getting increasingly more complex
▪ Windows XP > 40 million lines of code
▪ A single programmer cannot manage this amount of code
in its entirety.
❖ Code is not easily understandable by developers
who did not write it
❖ We need simpler representations for complex
systems
▪ Modeling is a means for dealing with complexity
Application and Solution Domain
❖ Application Domain (Requirements Analysis):
▪ The environment in which the system is operating
❖ Solution Domain (System Design, Object Design):
▪ The available technologies to build the system
Object-oriented Modeling
Application Domain
(Phenomena)
Solution Domain
(Phenomena)
System Model
(Concepts)
System Model
(Concepts)
Aircraft TrafficController
FlightPlan
Airpor
t
MapDispla
y
FlightPlanDatabas
e
Summary
Display
TrafficControl
TrafficContro
l
UML
Packag
e
(Analysis
)
(Design
)
What is UML?
❖ UML (Unified Modeling Language)
▪ Nonproprietary standard for modeling software systems, OMG
▪ Convergence of notations used in object-oriented methods
• OMT (James Rumbaugh and collegues)
• Booch (Grady Booch)
• OOSE (Ivar Jacobson)
❖ Current Version: UML 2.2
▪ Information at the OMG portal http://www.uml.org/
❖ Commercial tools: Rational (IBM),Together (Borland), Visual Architect
(business processes, BCD)
❖ Open Source tools: ArgoUML, StarUML, Umbrello
❖ Commercial and Opensource: PoseidonUML (Gentleware)
UML: First Pass
❖ You can model 80% of most problems by using
about 20% UML
❖ We teach you those 20%
❖ 80-20 rule: Pareto principle
(http://en.wikipedia.org/wiki/Pareto_principle)
▪ 80% of your profits come from 20% of your customers
▪ 80% of your complaints come from 20% of your customers
▪ 80% of your profits come from 20% of the time you spend
▪ 80% of your sales come from 20% of your products
UML First Pass
❖ Use case diagrams
▪ Describe the functional behavior of the system as seen by
the user
❖ Class diagrams
▪ Describe the static structure of the system: Objects,
attributes, associations
❖ Sequence diagrams
▪ Describe the dynamic behavior between objects of the
system
❖ State diagrams
▪ Describe the dynamic behavior of an individual object
UML Core Conventions
❖ All UML Diagrams denote graphs of nodes and
edges
▪ Nodes are entities and drawn as rectangles or ovals
▪ Rectangles denote classes or instances
▪ Ovals denote functions
• Names of Classes are not underlined
• SimpleWatch
• Firefighter
• Names of Instances are underlined
• myWatch:SimpleWatch
• Joe:Firefighter
• An edge between two nodes denotes a
relationship between the corresponding entities
UML first pass: Use case diagrams
Use case diagrams represent the functionality of the
system
from user’s point of view
Act
or
Use
Case
System
boundary
Classifie
r
UML first pass: Class diagrams
Clas
s
Associatio
n
Multiplicit
y
Class diagrams represent the structure of the
system
2
1 1
1
1
1
1
2
SimpleWatch
Display Battery Time
PushButton
UML first pass: Class diagrams
1
2
push()
release()
1
1
blinkIdx
blinkSeconds()
blinkMinutes()
blinkHours()
stopBlinking()
referesh()
LCDDisplay Battery
Load
1
2
1
Time
Now
1
Watch
Operatio
ns
state
PushButton
Attribut
e
Class diagrams represent the structure of the
system
Clas
s
Associatio
n
Multiplicit
y
Messa
ge
UML first pass: Sequence diagram
:Time
:Watch
:WatchUser
Objec
t
Activati
on
Sequence diagrams represent the behavior of a system
as messages (“interactions”) between different objects
Act
or
pressButton1()
Lifeline
blinkHours()
pressButton2()
incrementMinutes()
:LCDDisplay
pressButton1and2()
commitNewTime()
stopBlinking()
refresh()
pressButton1()
blinkMinutes()
UML first pass: Statechart diagrams
Stat
e
Initial
state
Final
state
Transiti
on
Even
t
Represent behavior of a single object with interesting
dynamic behavior.
button1&2Pressed
button1Pressed
button2Pressed
button2Pressed
button2Pressed
button1Pressed
button1&2Pressed Increment
Minutes
Increment
Hours
Blink
Hours
Blink
Seconds
Blink
Minutes
Increment
Seconds
Stop
Blinking
Other UML Notations
UML provides many other notations, for example
❖ Deployment diagrams for modeling
configurations
▪ Useful for testing and for release management
❖ We introduce these and other notations as we go
along in the lectures
▪ OCL: A language for constraining UML models
What should be done first? Coding or Modeling?
❖ It all depends….
❖ Forward Engineering
▪ Creation of code from a model
▪ Start with modeling
▪ Greenfield projects
❖ Reverse Engineering
▪ Creation of a model from existing code
▪ Interface or reengineering projects
❖ Roundtrip Engineering
▪ Move constantly between forward and reverse engineering
▪ Reengineering projects
▪ Useful when requirements, technology and schedule are changing
frequently.
UML Second Pass
❖ Use case diagrams
▪ Describe the functional behavior of the system as seen by the
user
❖ Class diagrams
▪ Describe the static structure of the system: Objects, attributes,
associations
❖ Sequence diagrams
▪ Describe the dynamic behavior between objects of the system
❖ State diagrams
▪ Describe the dynamic behavior of an individual object
❖ Activity diagrams
▪ Describe the dynamic behavior of a system, in particular the
workflow.
UML Use Case Diagrams
An Actor represents a role, that is, a type
of user of the system
Passenger
PurchaseTicket
Used during requirements elicitation
and analysis to represent external
behavior (“visible from the outside of
the system”)
Use case model:
The set of all use cases that
completely describe the functionality
of the system.
A use case represents a class of
functionality provided by the system
Actors
❖ An actor is a model for an external entity
which interacts (communicates) with the
system:
▪ User
▪ External system (Another system)
▪ Physical environment (e.g. Weather)
❖ An actor has a unique name and an
optional description
❖ Examples:
▪ Passenger: A person in the train
▪ GPS satellite: An external system that provides
the system with GPS coordinates.
Passenger
Name
Optional
Description
Use Case
• A use case represents a class of
functionality provided by the system
• Use cases can be described textually, with
a focus on the event flow between actor
and system
• The textual use case description consists
of 6 parts:
1. Unique name
2. Participating actors
3. Entry conditions
4. Exit conditions
5. Flow of events
6. Special requirements.
PurchaseTicket
Textual Use Case
Description Example
1. Name: Purchase ticket
2. Participating actor: Passenger
3. Entry condition:
❖ Passenger stands in front of
ticket distributor
❖ Passenger has sufficient
money to purchase ticket
4. Exit condition:
❖ Passenger has ticket
5. Flow of events:
1. Passenger selects the
number of zones to be
traveled
2. Ticket Distributor displays the
amount due
3. Passenger inserts money, at
least the amount due
4. Ticket Distributor returns
change
5. Ticket Distributor issues ticket
6. Special requirements: None.
Passenge
r
PurchaseTicke
t
Uses Cases can be related
❖ Extends Relationship
▪ To represent seldom invoked use cases or exceptional
functionality
❖ Includes Relationship
▪ To represent functional behavior common to more than
one use case.
The <<extends>>Relationship
❖ <<extends>> relationships model
exceptional or seldom invoked cases
❖ The exceptional event flows are
factored out of the main event flow
for clarity
❖ The direction of an <<extends>>
relationship is to the extended use
case
❖ Use cases representing exceptional
flows can extend more than one use
case.
Passenger
PurchaseTicket
TimeOut
<<extends>
>
NoChange
<<extends>
>
OutOfOrder
<<extends>
>
Cancel
<<extends>
>
The <<includes>> Relationship
❖ <<includes>> relationship
represents common functionality
needed in more than one use
case
❖ <<includes>> behavior is
factored out for reuse, not
because it is an exception
❖ The direction of a
<<includes>> relationship is
to the using use case (unlike the
direction of the <<extends>>
relationship).
Passenger
PurchaseSingleTicket
PurchaseMultiCard
<<includes>
>
CollectMoney
<<includes>
>
NoChange
<<extends>
>
Cancel
<<extends>
>
Cancel
<<extends>
>
Class Diagrams
❖ Class diagrams represent the structure of the system
❖ Used
▪ during requirements analysis to model application domain
concepts
▪ during system design to model subsystems
▪ during object design to specify the detailed behavior and
attributes of classes.
Table zone2price
Enumeration getZones()
Price getPrice(Zone)
TarifSchedule
* *
Trip
zone:Zone
Price: Price
Classes
❖ A class represents a concept
❖ A class encapsulates state (attributes) and behavior (operations)
Table zone2price
Enumeration getZones()
Price getPrice(Zone)
TarifSchedule
zone2price
getZones()
getPrice()
TarifSchedule
Name
Attributes
Operation
s
Signature
TarifSchedule
The class name is the only mandatory information
Each attribute has a type
Each operation has a signature
Type
Actor vs Class vs Object
❖ Actor
▪ An entity outside the system to be modeled, interacting
with the system (“Passenger”)
❖ Class
▪ An abstraction modeling an entity in the application or
solution domain
▪ The class is part of the system model (“User”, “Ticket
distributor”, “Server”)
❖ Object
▪ A specific instance of a class (“Joe, the passenger who is
purchasing a ticket from the ticket distributor”).
Associations
Associations denote relationships between classes
Price
Zone
Enumeration getZones()
Price getPrice(Zone)
TarifSchedule TripLeg
* *
The multiplicity of an association end denotes how many
objects the instance of a class can legitimately reference.
1-to-1 and 1-to-many Associations
1-to-1 association
1-to-many association
Polygon
draw()
Point
x:
Integer
y:
Integer
*
Country
name:Strin
g
City
name:Strin
g
1
1
Many-to-Many Associations
StockExchange
Compan
y
tickerSymbol
*
*
From Problem Statement To Object Model
Class Diagram:
StockExchange Compan
y
tickerSymbol
Lists
*
*
Problem Statement: A stock exchange lists many companies.
Each company is uniquely identified by a ticker symbol
From Problem Statement to Code
Problem Statement : A stock exchange lists many companies.
Each company is identified by a ticker
symbol
Class Diagram:
private Vector m_Company = new
Vector();
public int m_tickerSymbol;
private Vector m_StockExchange = new
Vector();
public class StockExchange
{
};
public class Company
{
};
Java
Code
StockExchange Company
tickerSymbol
Lists
*
*
Associations
are mapped to
Attributes!
Aggregation
❖ An aggregation is a special case of association denoting a “consists-
of” hierarchy
❖ The aggregate is the parent class,
the components are the children classes
Exhaust system
Muffle
r
diamete
r
Tailpipe
diamete
r
1 0..2
TicketMachine
ZoneButton
3
A solid diamond denotes composition: A strong form of
aggregation where the life time of the component instances
is controlled by the aggregate. That is, the parts don’t exist
on their won (“the whole controls/destroys the parts”)
Inheritance
❖ Inheritance is another special case of an association
denoting a “kind-of” hierarchy
❖ Inheritance simplifies the analysis model by introducing a
taxonomy
❖ The children classes inherit the attributes and operations
of the parent class.
Button
ZoneButton
CancelButton
Packages
❖ Packages help you to organize UML models to increase their
readability
❖ We can use the UML package mechanism to organize classes
into subsystems
❖ Any complex system can be decomposed into subsystems,
where each subsystem is modeled as a package.
Account
Customer
Bank
Object Modeling in Practice
Class Identification: Name of Class, Attributes and
Methods
Is Foo the right
name?
Fo
o
Amount
CustomerI
d
Deposit(
)
Withdraw()
GetBalance(
)
Object Modeling in Practice: Brainstorming
Fo
o
Amount
CustomerI
d
Deposit(
)
Withdraw()
GetBalance(
) Accoun
t
Amount
CustomerI
d
Deposit(
)
Withdraw()
GetBalance(
)
Is Foo the right
name?
“Dada”
Amount
CustomerI
d
Deposit(
)
Withdraw()
GetBalance(
)
Object Modeling in Practice: More classes
Accoun
t
Amount
Deposit(
)
Withdraw()
GetBalance(
)
Custome
r
Name
CustomerI
d
CustomerI
d
AccountI
d
Ban
k
Name
1) Find New
Classes
2) Review Names, Attributes and
Methods
Object Modeling in Practice: Associations
Accoun
t
Amount
Deposit(
)
Withdraw()
GetBalance(
)
Custome
r
Name
CustomerI
d
CustomerI
d
AccountI
d
AccountI
d
Ban
k
Name
1) Find New
Classes
2) Review Names, Attributes and
Methods
3) Find Associations between Classes
own
s
4) Label the generic
assocations
6) Review associations
*
2
*
?
ha
s
5) Determine the multiplicity of the
assocations
Practice Object Modeling: Find Taxonomies
Saving
s
Accoun
t
Withdraw()
Checkin
g
Account
Withdraw()
Mortgag
e
Account
Withdraw()
Accoun
t
Amount
Deposit(
)
Withdraw()
GetBalance(
)
CustomerI
d
AccountI
d
AccountI
d
Custome
r
Name
CustomerId(
)
Ha
s
*
Ban
k
Name
*
Practice Object Modeling: Simplify, Organize
Saving
s
Accoun
t
Withdraw()
Checkin
g
Account
Withdraw()
Mortgag
e
Account
Withdraw()
Accoun
t
Amount
Deposit(
)
Withdraw()
GetBalance(
)
CustomerI
d
AccountI
d
AccountI
d
Show Taxonomies
separately
Practice Object Modeling: Simplify, Organize
Custome
r
Name
CustomerId(
)
Accoun
t
Amount
Deposit(
)
Withdraw()
GetBalance(
)
CustomerI
d
AccountI
d
AccountI
d
Ban
k
Name Ha
s
*
*
Use the 7+-2 heuristics
or better 5+-2!
Sequence Diagrams
❖ Used during analysis
▪ To refine use case descriptions
▪ to find additional objects
(“participating objects”)
❖ Used during system design
▪ to refine subsystem interfaces
❖ Instances are represented by
rectangles. Actors by sticky figures
❖ Lifelines are represented by dashed
lines
❖ Messages are represented by arrows
❖ Activations are represented by
narrow rectangles.
selectZone()
pickupChange()
pickUpTicket()
insertCoins()
TicketMachine
Passenger
Focus on
control flow
Messages ->
Operations on
participating
Object
zone2price
selectZone()
insertCoins()
pickupChange()
pickUpTicket()
TicketMachine
Sequence Diagrams can also model the Flow of
Data
❖ The source of an arrow indicates the activation which sent the
message
❖ Horizontal dashed arrows indicate data flow, for example return
results from a message
Passenger
selectZone()
ZoneButton TarifSchedule Display
lookupPrice(selection)
displayPrice(price)
price
Dataflo
w
…continued on next slide...
Sequence Diagrams: Iteration & Condition
❖ Iteration is denoted by a * preceding the message name
❖ Condition is denoted by boolean expression in [ ] before the
message name
Passenger
ChangeProcessor
insertChange(coin)
CoinIdentifier Display CoinDrop
displayPrice(owedAmount)
lookupCoin(coin)
price
[owedAmount<0] returnChange(-owedAmount)
Iteratio
n
Conditio
n
…continued on next slide...
…continued from previous slide...
*
Creation and destruction
❖ Creation is denoted by a message arrow pointing to the object
❖ Destruction is denoted by an X mark at the end of the destruction activation
▪ In garbage collection environments, destruction can be used to denote the end
of the useful life of an object.
Passenger
ChangeProcessor
…continued from previous slide...
Ticket
createTicket(selection)
free()
Creation of
Ticket
Destruction of
Ticket
print()
Sequence Diagram Properties
❖ UML sequence diagram represent behavior in
terms of interactions
❖ Useful to identify or find missing objects
❖ Time consuming to build, but worth the
investment
❖ Complement the class diagrams (which represent
structure).
Activity Diagrams
❖ An activity diagram is a special case of a state chart
diagram
❖ The states are activities (“functions”)
❖ An activity diagram is useful to depict the workflow
in a system
Activity Diagrams allow to model Decisions
Decision
Activity Diagrams can model Concurrency
❖ Synchronization of multiple activities
❖ Splitting the flow of control into multiple threads
Synchroniz
ation
Splitting
Activity Diagrams: Grouping of Activities
❖ Activities may be grouped into swimlanes to
denote the object or subsystem that implements
the activities.
Ope
n
Inciden
t
Allocat
e
Resource
s
Coordinat
e
Resource
s
Documen
t
Inciden
t
Archiv
e
Inciden
t
Dispatche
r
FieldOffice
r
Activity Diagram vs. Statechart Diagram
Active Inactive Closed Archived
Incident-
Handled
Incident-
Documented
Incident-
Archived
Statechart Diagram for Incident
Focus on the set of attributes of a single abstraction (object, system)
Activity Diagram for Incident
(Focus on dataflow in a system)
Triggerles
s
transition
Completion of activity
causes state transition
Event causes
state
transition
UML Summary
❖ UML provides a wide variety of notations for
representing many aspects of software
development
▪ Powerful, but complex
❖ UML is a programming language
▪ Can be misused to generate unreadable models
▪ Can be misunderstood when using too many exotic features
❖ We concentrated on a few notations:
▪ Functional model: Use case diagram
▪ Object model: class diagram
▪ Dynamic model: sequence diagrams, statechart and activity
diagrams
Additional References
❖ Martin Fowler
▪ UML Distilled: A Brief Guide to the Standard Object Modeling
Language, 3rd ed., Addison-Wesley, 2003
❖ Grady Booch,James Rumbaugh,Ivar Jacobson
▪ The Unified Modeling Language User Guide, Addison Wesley, 2nd
edition, 2005
❖ Commercial UML tools
▪ Rational Rose XDE for Java
• http://www-306.ibm.com/software/awdtools/developer/java/
▪ Together (Eclipse, MS Visual Studio, JBuilder)
• http://www.borland.com/us/products/together/index.html
❖ Open Source UML tools
▪ http://java-source.net/open-source/uml-modeling
▪ ArgoUML,UMLet,Violet, …
Thank you
for your
attentions!
57

More Related Content

Similar to 02_IT4557.pptx

Similar to 02_IT4557.pptx (20)

CASE Tools lab.ppt
CASE Tools lab.pptCASE Tools lab.ppt
CASE Tools lab.ppt
 
Unit 1- OOAD ppt
Unit 1- OOAD  pptUnit 1- OOAD  ppt
Unit 1- OOAD ppt
 
CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3
 
analysis and design with uml
analysis and design with umlanalysis and design with uml
analysis and design with uml
 
Week 5
Week 5Week 5
Week 5
 
chapter_5_5.ppt
chapter_5_5.pptchapter_5_5.ppt
chapter_5_5.ppt
 
Cs8592 ooad unit 1
Cs8592 ooad unit 1Cs8592 ooad unit 1
Cs8592 ooad unit 1
 
Cs8592 ooad unit 1
Cs8592 ooad unit 1Cs8592 ooad unit 1
Cs8592 ooad unit 1
 
Introducing Uml And Development Process
Introducing Uml And Development ProcessIntroducing Uml And Development Process
Introducing Uml And Development Process
 
OOAD U1.pptx
OOAD U1.pptxOOAD U1.pptx
OOAD U1.pptx
 
System Modelling.ppt
System Modelling.pptSystem Modelling.ppt
System Modelling.ppt
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
 
Modeling software with UML
Modeling software with UMLModeling software with UML
Modeling software with UML
 
Unified Modeling Language - UML - Complete Guide - Part 1
Unified Modeling Language - UML - Complete Guide - Part 1Unified Modeling Language - UML - Complete Guide - Part 1
Unified Modeling Language - UML - Complete Guide - Part 1
 
Uml and enterprise architect
Uml and enterprise architectUml and enterprise architect
Uml and enterprise architect
 
Ch 14 s.e use case diagrams
Ch 14 s.e use case diagramsCh 14 s.e use case diagrams
Ch 14 s.e use case diagrams
 
Use case modeling
Use case modelingUse case modeling
Use case modeling
 
Introduction to OOA and UML
Introduction to OOA and UMLIntroduction to OOA and UML
Introduction to OOA and UML
 
MDE in Practice
MDE in PracticeMDE in Practice
MDE in Practice
 
Ch02lect1 ud
Ch02lect1 udCh02lect1 ud
Ch02lect1 ud
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 

02_IT4557.pptx

  • 2. Overview: modeling with UML ❖ What is modeling? ❖ What is UML? ❖ Use case diagrams ❖ Class diagrams ❖ Sequence diagrams ❖ Activity diagrams
  • 3. What is modeling? ❖ Modeling consists of building an abstraction of reality. ❖ Abstractions are simplifications because: ▪ They ignore irrelevant details and ▪ They only represent the relevant details. ❖ What is relevant or irrelevant depends on the purpose of the model.
  • 5. Why model software? Why model software? ❖ Software is getting increasingly more complex ▪ Windows XP > 40 million lines of code ▪ A single programmer cannot manage this amount of code in its entirety. ❖ Code is not easily understandable by developers who did not write it ❖ We need simpler representations for complex systems ▪ Modeling is a means for dealing with complexity
  • 6. Application and Solution Domain ❖ Application Domain (Requirements Analysis): ▪ The environment in which the system is operating ❖ Solution Domain (System Design, Object Design): ▪ The available technologies to build the system
  • 7. Object-oriented Modeling Application Domain (Phenomena) Solution Domain (Phenomena) System Model (Concepts) System Model (Concepts) Aircraft TrafficController FlightPlan Airpor t MapDispla y FlightPlanDatabas e Summary Display TrafficControl TrafficContro l UML Packag e (Analysis ) (Design )
  • 8. What is UML? ❖ UML (Unified Modeling Language) ▪ Nonproprietary standard for modeling software systems, OMG ▪ Convergence of notations used in object-oriented methods • OMT (James Rumbaugh and collegues) • Booch (Grady Booch) • OOSE (Ivar Jacobson) ❖ Current Version: UML 2.2 ▪ Information at the OMG portal http://www.uml.org/ ❖ Commercial tools: Rational (IBM),Together (Borland), Visual Architect (business processes, BCD) ❖ Open Source tools: ArgoUML, StarUML, Umbrello ❖ Commercial and Opensource: PoseidonUML (Gentleware)
  • 9. UML: First Pass ❖ You can model 80% of most problems by using about 20% UML ❖ We teach you those 20% ❖ 80-20 rule: Pareto principle (http://en.wikipedia.org/wiki/Pareto_principle) ▪ 80% of your profits come from 20% of your customers ▪ 80% of your complaints come from 20% of your customers ▪ 80% of your profits come from 20% of the time you spend ▪ 80% of your sales come from 20% of your products
  • 10. UML First Pass ❖ Use case diagrams ▪ Describe the functional behavior of the system as seen by the user ❖ Class diagrams ▪ Describe the static structure of the system: Objects, attributes, associations ❖ Sequence diagrams ▪ Describe the dynamic behavior between objects of the system ❖ State diagrams ▪ Describe the dynamic behavior of an individual object
  • 11. UML Core Conventions ❖ All UML Diagrams denote graphs of nodes and edges ▪ Nodes are entities and drawn as rectangles or ovals ▪ Rectangles denote classes or instances ▪ Ovals denote functions • Names of Classes are not underlined • SimpleWatch • Firefighter • Names of Instances are underlined • myWatch:SimpleWatch • Joe:Firefighter • An edge between two nodes denotes a relationship between the corresponding entities
  • 12. UML first pass: Use case diagrams Use case diagrams represent the functionality of the system from user’s point of view Act or Use Case System boundary Classifie r
  • 13. UML first pass: Class diagrams Clas s Associatio n Multiplicit y Class diagrams represent the structure of the system 2 1 1 1 1 1 1 2 SimpleWatch Display Battery Time PushButton
  • 14. UML first pass: Class diagrams 1 2 push() release() 1 1 blinkIdx blinkSeconds() blinkMinutes() blinkHours() stopBlinking() referesh() LCDDisplay Battery Load 1 2 1 Time Now 1 Watch Operatio ns state PushButton Attribut e Class diagrams represent the structure of the system Clas s Associatio n Multiplicit y
  • 15. Messa ge UML first pass: Sequence diagram :Time :Watch :WatchUser Objec t Activati on Sequence diagrams represent the behavior of a system as messages (“interactions”) between different objects Act or pressButton1() Lifeline blinkHours() pressButton2() incrementMinutes() :LCDDisplay pressButton1and2() commitNewTime() stopBlinking() refresh() pressButton1() blinkMinutes()
  • 16. UML first pass: Statechart diagrams Stat e Initial state Final state Transiti on Even t Represent behavior of a single object with interesting dynamic behavior. button1&2Pressed button1Pressed button2Pressed button2Pressed button2Pressed button1Pressed button1&2Pressed Increment Minutes Increment Hours Blink Hours Blink Seconds Blink Minutes Increment Seconds Stop Blinking
  • 17. Other UML Notations UML provides many other notations, for example ❖ Deployment diagrams for modeling configurations ▪ Useful for testing and for release management ❖ We introduce these and other notations as we go along in the lectures ▪ OCL: A language for constraining UML models
  • 18. What should be done first? Coding or Modeling? ❖ It all depends…. ❖ Forward Engineering ▪ Creation of code from a model ▪ Start with modeling ▪ Greenfield projects ❖ Reverse Engineering ▪ Creation of a model from existing code ▪ Interface or reengineering projects ❖ Roundtrip Engineering ▪ Move constantly between forward and reverse engineering ▪ Reengineering projects ▪ Useful when requirements, technology and schedule are changing frequently.
  • 19. UML Second Pass ❖ Use case diagrams ▪ Describe the functional behavior of the system as seen by the user ❖ Class diagrams ▪ Describe the static structure of the system: Objects, attributes, associations ❖ Sequence diagrams ▪ Describe the dynamic behavior between objects of the system ❖ State diagrams ▪ Describe the dynamic behavior of an individual object ❖ Activity diagrams ▪ Describe the dynamic behavior of a system, in particular the workflow.
  • 20. UML Use Case Diagrams An Actor represents a role, that is, a type of user of the system Passenger PurchaseTicket Used during requirements elicitation and analysis to represent external behavior (“visible from the outside of the system”) Use case model: The set of all use cases that completely describe the functionality of the system. A use case represents a class of functionality provided by the system
  • 21. Actors ❖ An actor is a model for an external entity which interacts (communicates) with the system: ▪ User ▪ External system (Another system) ▪ Physical environment (e.g. Weather) ❖ An actor has a unique name and an optional description ❖ Examples: ▪ Passenger: A person in the train ▪ GPS satellite: An external system that provides the system with GPS coordinates. Passenger Name Optional Description
  • 22. Use Case • A use case represents a class of functionality provided by the system • Use cases can be described textually, with a focus on the event flow between actor and system • The textual use case description consists of 6 parts: 1. Unique name 2. Participating actors 3. Entry conditions 4. Exit conditions 5. Flow of events 6. Special requirements. PurchaseTicket
  • 23. Textual Use Case Description Example 1. Name: Purchase ticket 2. Participating actor: Passenger 3. Entry condition: ❖ Passenger stands in front of ticket distributor ❖ Passenger has sufficient money to purchase ticket 4. Exit condition: ❖ Passenger has ticket 5. Flow of events: 1. Passenger selects the number of zones to be traveled 2. Ticket Distributor displays the amount due 3. Passenger inserts money, at least the amount due 4. Ticket Distributor returns change 5. Ticket Distributor issues ticket 6. Special requirements: None. Passenge r PurchaseTicke t
  • 24. Uses Cases can be related ❖ Extends Relationship ▪ To represent seldom invoked use cases or exceptional functionality ❖ Includes Relationship ▪ To represent functional behavior common to more than one use case.
  • 25. The <<extends>>Relationship ❖ <<extends>> relationships model exceptional or seldom invoked cases ❖ The exceptional event flows are factored out of the main event flow for clarity ❖ The direction of an <<extends>> relationship is to the extended use case ❖ Use cases representing exceptional flows can extend more than one use case. Passenger PurchaseTicket TimeOut <<extends> > NoChange <<extends> > OutOfOrder <<extends> > Cancel <<extends> >
  • 26. The <<includes>> Relationship ❖ <<includes>> relationship represents common functionality needed in more than one use case ❖ <<includes>> behavior is factored out for reuse, not because it is an exception ❖ The direction of a <<includes>> relationship is to the using use case (unlike the direction of the <<extends>> relationship). Passenger PurchaseSingleTicket PurchaseMultiCard <<includes> > CollectMoney <<includes> > NoChange <<extends> > Cancel <<extends> > Cancel <<extends> >
  • 27. Class Diagrams ❖ Class diagrams represent the structure of the system ❖ Used ▪ during requirements analysis to model application domain concepts ▪ during system design to model subsystems ▪ during object design to specify the detailed behavior and attributes of classes. Table zone2price Enumeration getZones() Price getPrice(Zone) TarifSchedule * * Trip zone:Zone Price: Price
  • 28. Classes ❖ A class represents a concept ❖ A class encapsulates state (attributes) and behavior (operations) Table zone2price Enumeration getZones() Price getPrice(Zone) TarifSchedule zone2price getZones() getPrice() TarifSchedule Name Attributes Operation s Signature TarifSchedule The class name is the only mandatory information Each attribute has a type Each operation has a signature Type
  • 29. Actor vs Class vs Object ❖ Actor ▪ An entity outside the system to be modeled, interacting with the system (“Passenger”) ❖ Class ▪ An abstraction modeling an entity in the application or solution domain ▪ The class is part of the system model (“User”, “Ticket distributor”, “Server”) ❖ Object ▪ A specific instance of a class (“Joe, the passenger who is purchasing a ticket from the ticket distributor”).
  • 30. Associations Associations denote relationships between classes Price Zone Enumeration getZones() Price getPrice(Zone) TarifSchedule TripLeg * * The multiplicity of an association end denotes how many objects the instance of a class can legitimately reference.
  • 31. 1-to-1 and 1-to-many Associations 1-to-1 association 1-to-many association Polygon draw() Point x: Integer y: Integer * Country name:Strin g City name:Strin g 1 1
  • 33. From Problem Statement To Object Model Class Diagram: StockExchange Compan y tickerSymbol Lists * * Problem Statement: A stock exchange lists many companies. Each company is uniquely identified by a ticker symbol
  • 34. From Problem Statement to Code Problem Statement : A stock exchange lists many companies. Each company is identified by a ticker symbol Class Diagram: private Vector m_Company = new Vector(); public int m_tickerSymbol; private Vector m_StockExchange = new Vector(); public class StockExchange { }; public class Company { }; Java Code StockExchange Company tickerSymbol Lists * * Associations are mapped to Attributes!
  • 35. Aggregation ❖ An aggregation is a special case of association denoting a “consists- of” hierarchy ❖ The aggregate is the parent class, the components are the children classes Exhaust system Muffle r diamete r Tailpipe diamete r 1 0..2 TicketMachine ZoneButton 3 A solid diamond denotes composition: A strong form of aggregation where the life time of the component instances is controlled by the aggregate. That is, the parts don’t exist on their won (“the whole controls/destroys the parts”)
  • 36. Inheritance ❖ Inheritance is another special case of an association denoting a “kind-of” hierarchy ❖ Inheritance simplifies the analysis model by introducing a taxonomy ❖ The children classes inherit the attributes and operations of the parent class. Button ZoneButton CancelButton
  • 37. Packages ❖ Packages help you to organize UML models to increase their readability ❖ We can use the UML package mechanism to organize classes into subsystems ❖ Any complex system can be decomposed into subsystems, where each subsystem is modeled as a package. Account Customer Bank
  • 38. Object Modeling in Practice Class Identification: Name of Class, Attributes and Methods Is Foo the right name? Fo o Amount CustomerI d Deposit( ) Withdraw() GetBalance( )
  • 39. Object Modeling in Practice: Brainstorming Fo o Amount CustomerI d Deposit( ) Withdraw() GetBalance( ) Accoun t Amount CustomerI d Deposit( ) Withdraw() GetBalance( ) Is Foo the right name? “Dada” Amount CustomerI d Deposit( ) Withdraw() GetBalance( )
  • 40. Object Modeling in Practice: More classes Accoun t Amount Deposit( ) Withdraw() GetBalance( ) Custome r Name CustomerI d CustomerI d AccountI d Ban k Name 1) Find New Classes 2) Review Names, Attributes and Methods
  • 41. Object Modeling in Practice: Associations Accoun t Amount Deposit( ) Withdraw() GetBalance( ) Custome r Name CustomerI d CustomerI d AccountI d AccountI d Ban k Name 1) Find New Classes 2) Review Names, Attributes and Methods 3) Find Associations between Classes own s 4) Label the generic assocations 6) Review associations * 2 * ? ha s 5) Determine the multiplicity of the assocations
  • 42. Practice Object Modeling: Find Taxonomies Saving s Accoun t Withdraw() Checkin g Account Withdraw() Mortgag e Account Withdraw() Accoun t Amount Deposit( ) Withdraw() GetBalance( ) CustomerI d AccountI d AccountI d Custome r Name CustomerId( ) Ha s * Ban k Name *
  • 43. Practice Object Modeling: Simplify, Organize Saving s Accoun t Withdraw() Checkin g Account Withdraw() Mortgag e Account Withdraw() Accoun t Amount Deposit( ) Withdraw() GetBalance( ) CustomerI d AccountI d AccountI d Show Taxonomies separately
  • 44. Practice Object Modeling: Simplify, Organize Custome r Name CustomerId( ) Accoun t Amount Deposit( ) Withdraw() GetBalance( ) CustomerI d AccountI d AccountI d Ban k Name Ha s * * Use the 7+-2 heuristics or better 5+-2!
  • 45. Sequence Diagrams ❖ Used during analysis ▪ To refine use case descriptions ▪ to find additional objects (“participating objects”) ❖ Used during system design ▪ to refine subsystem interfaces ❖ Instances are represented by rectangles. Actors by sticky figures ❖ Lifelines are represented by dashed lines ❖ Messages are represented by arrows ❖ Activations are represented by narrow rectangles. selectZone() pickupChange() pickUpTicket() insertCoins() TicketMachine Passenger Focus on control flow Messages -> Operations on participating Object zone2price selectZone() insertCoins() pickupChange() pickUpTicket() TicketMachine
  • 46. Sequence Diagrams can also model the Flow of Data ❖ The source of an arrow indicates the activation which sent the message ❖ Horizontal dashed arrows indicate data flow, for example return results from a message Passenger selectZone() ZoneButton TarifSchedule Display lookupPrice(selection) displayPrice(price) price Dataflo w …continued on next slide...
  • 47. Sequence Diagrams: Iteration & Condition ❖ Iteration is denoted by a * preceding the message name ❖ Condition is denoted by boolean expression in [ ] before the message name Passenger ChangeProcessor insertChange(coin) CoinIdentifier Display CoinDrop displayPrice(owedAmount) lookupCoin(coin) price [owedAmount<0] returnChange(-owedAmount) Iteratio n Conditio n …continued on next slide... …continued from previous slide... *
  • 48. Creation and destruction ❖ Creation is denoted by a message arrow pointing to the object ❖ Destruction is denoted by an X mark at the end of the destruction activation ▪ In garbage collection environments, destruction can be used to denote the end of the useful life of an object. Passenger ChangeProcessor …continued from previous slide... Ticket createTicket(selection) free() Creation of Ticket Destruction of Ticket print()
  • 49. Sequence Diagram Properties ❖ UML sequence diagram represent behavior in terms of interactions ❖ Useful to identify or find missing objects ❖ Time consuming to build, but worth the investment ❖ Complement the class diagrams (which represent structure).
  • 50. Activity Diagrams ❖ An activity diagram is a special case of a state chart diagram ❖ The states are activities (“functions”) ❖ An activity diagram is useful to depict the workflow in a system
  • 51. Activity Diagrams allow to model Decisions Decision
  • 52. Activity Diagrams can model Concurrency ❖ Synchronization of multiple activities ❖ Splitting the flow of control into multiple threads Synchroniz ation Splitting
  • 53. Activity Diagrams: Grouping of Activities ❖ Activities may be grouped into swimlanes to denote the object or subsystem that implements the activities. Ope n Inciden t Allocat e Resource s Coordinat e Resource s Documen t Inciden t Archiv e Inciden t Dispatche r FieldOffice r
  • 54. Activity Diagram vs. Statechart Diagram Active Inactive Closed Archived Incident- Handled Incident- Documented Incident- Archived Statechart Diagram for Incident Focus on the set of attributes of a single abstraction (object, system) Activity Diagram for Incident (Focus on dataflow in a system) Triggerles s transition Completion of activity causes state transition Event causes state transition
  • 55. UML Summary ❖ UML provides a wide variety of notations for representing many aspects of software development ▪ Powerful, but complex ❖ UML is a programming language ▪ Can be misused to generate unreadable models ▪ Can be misunderstood when using too many exotic features ❖ We concentrated on a few notations: ▪ Functional model: Use case diagram ▪ Object model: class diagram ▪ Dynamic model: sequence diagrams, statechart and activity diagrams
  • 56. Additional References ❖ Martin Fowler ▪ UML Distilled: A Brief Guide to the Standard Object Modeling Language, 3rd ed., Addison-Wesley, 2003 ❖ Grady Booch,James Rumbaugh,Ivar Jacobson ▪ The Unified Modeling Language User Guide, Addison Wesley, 2nd edition, 2005 ❖ Commercial UML tools ▪ Rational Rose XDE for Java • http://www-306.ibm.com/software/awdtools/developer/java/ ▪ Together (Eclipse, MS Visual Studio, JBuilder) • http://www.borland.com/us/products/together/index.html ❖ Open Source UML tools ▪ http://java-source.net/open-source/uml-modeling ▪ ArgoUML,UMLet,Violet, …