Post on 18-Feb-2018
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 1/56
U s i n g U M L , P a t t e r n s , a n d
J a v a
b e c t - r
e n t e d
o t w a r e E n g n
e e r n g Chapter 2,
Modeling with UML
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 2/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2
Overview: modeling with UML
♦ What is modeling?♦ What is UML?
♦ Use case diagrams
♦ Class diagrams
♦ Sequence diagrams
♦ Activity diagrams
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 3/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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 themodel.
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 4/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4
Example: street map
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 5/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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 itsentirety.
♦ Code is not easily understandable by developers who did notwrite it
♦
We need simpler representations for complex systems Modeling is a means for dealing with complexity
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 6/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 7/56Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7
Object-oriented Modeling
Application Domain(Phenomena)
Solution Domain(Phenomena)
System Model (Concepts) System Model (Concepts)
Aircraft TrafficController
FlightPlanAirport
MapDisplay
FlightPlanDatabase
Summary
Display
TrafficControl
TrafficControl
UMLPackage
(Analysis) (Design)
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 8/56Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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)
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 9/56Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 10/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10
UML First Pass
♦ Use case diagrams
Describe the functional behavior of the system as seen by theuser
♦ 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
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 11/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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 arelationship between the corresponding entities
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 12/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12
UML first pass: Use case diagrams
Use case diagrams represent the functionality of the systemfrom user’s point of view
Actor
Use Case
System boundary
Classifier
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 13/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13
UML first pass: Class diagrams
ClassAssociation
Multiplicity
Class diagrams represent the structure of the system
21 1
1
1
1
1
2
SimpleWatch
Display Battery TimePushButton
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 14/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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
Operations
state
PushButton
Attribute
Class diagrams represent the structure of the system
ClassAssociation
Multiplicity
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 15/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15
Message
UML first pass: Sequence diagram
:Time:Watch:WatchUser
Object
Activation
Sequence diagrams represent the behavior of a system
as messages (“interactions”) between different objects
Actor
pressButton1()
Lifeline
blinkHours()
pressButton2()incrementMinutes()
:LCDDisplay
pressButton1and2()
commitNewTime()
stopBlinking()
refresh()
pressButton1()blinkMinutes()
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 16/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16
UML first pass: Statechart diagrams
State
Initial state
Final state
Transition
Event
Represent behavior ofa single object with interestingdynamic behavior.
button1&2Pressed
button1Pressed
button2Pressed
button2Pressed
button2Pressed
button1Pressed
button1&2Pressed IncrementMinutes
IncrementHoursBlinkHours
BlinkSeconds
BlinkMinutes
IncrementSeconds
StopBlinking
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 17/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 18/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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 changingfrequently.
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 19/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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.
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 20/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20
UML Use Case Diagrams
An Actor represents a role, that is, a typeof user of the system
Passenger
PurchaseTicket
Used during requirements elicitation
and analysis to represent externalbehavior (“visible from the outside ofthe system!
Use case model "
#he set of all use cases thatcompletely describe thefunctionality of the system$
A use case represents a class offunctionality provided by the system
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 21/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21
Actors
♦ An actor is a model for an external entity
which interacts (communicates) with thesystem:
User
External system (Another system)
Physical environment (e.g. Weather)
♦ An actor has a unique name and an optionaldescription
♦ Examples:
Passenger: A person in the train GPS satellite: An external system that provides
the system with GPS coordinates.
Passenger
Name
OptionalDescription
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 22/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22
Use Case
• A use case represents a class offunctionality provided by the system
• Use cases can be described textually, with afocus on the event flow between actor andsystem
• 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
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 23/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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 sufficientmoney to purchase ticket
4. Exit condition:
♦ Passenger has ticket
5. Flow of events:
1. Passenger selects thenumber of zones to be traveled
2. Ticket Distributor displaysthe amount due
3. Passenger inserts money, atleast the amount due
4. Ticket Distributor returnschange
5. Ticket Distributor issues ticket
6. Special requirements: None.
Passenger PurchaseTicket
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 24/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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 usecase.
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 25/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25
The <<extends>> Relationship
♦ <<extends>> relationships modelexceptional or seldom invoked cases
♦ The exceptional event flows arefactored out of the main event flow forclarity
♦ The direction of an <<extends>> relationship is to the extended use case
♦ Use cases representing exceptionalflows can extend more than one usecase.
Passenger
PurchaseTicket
TimeOut
<<extends>>
NoChange
<<extends>>OutOfOrder
<<extends>>
Cancel
<<extends>>
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 26/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26
The <<includes>> Relationship
♦ <<includes>> relationship
represents common functionalityneeded in more than one use case
♦ <<includes>> behavior isfactored out for reuse, not because itis 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>>
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 27/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 27
Class Diagrams
♦
Class diagrams represent the structure of the system♦ Used
during requirements analysis to model application domainconcepts
during system design to model subsystems
during object design to specify the detailed behavior andattributes of classes.
Table zone2price
Enumeration getZones()
Price getPrice(Zone)
TarifSchedule
* *
Trip
zone:Zone
Price: Price
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 28/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 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
Operations
Signature
TarifSchedule
#he class name is the only mandatory information
%ach attribute has a type%ach operation has a signature
Type
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 29/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30
Actor vs Class vs Object
♦ Actor
An entity outside the system to be modeled, interacting with thesystem (“Passenger”)
♦ Class
An abstraction modeling an entity in the application or solutiondomain
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”).
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 30/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31
Associations
Associations denote relationships between classes
Price
ZoneEnumeration getZones()
Price getPrice(Zone)
TarifSchedule TripLeg
* *
#he multiplicity of an association end denotes how manyob&ects the instance of a class can legitimately reference$
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 31/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32
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:String
City
name:String
11
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 32/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33
Many-to-Many Associations
StockExchange
Company
tickerSymbol**
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 33/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34
From Problem Statement To Object Model
Class Diagram:
StockExchange Company
tickerSymbol Lists
**
Problem Statement: A stock exchange lists many companies. Each company is uniquely identified by a ticker symbol
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 34/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 35
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
**
Associationsare mapped toAttributes!
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 35/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36
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
Muffler
diameter
Tailpipe
diameter
1 0..2
TicketMachine
ZoneButton
3
A solid diamond denotes composition" A strong form ofaggregation where the life time of the componentinstances is controlled by the aggregate$ #hat is' the parts
dont exist on their won (“the whole controls)destroys theparts!
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 36/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 39
Inheritance
♦ Inheritance is another special case of an association denoting a“kind-of” hierarchy
♦ Inheritance simplifies the analysis model by introducing ataxonomy
♦ The children classes inherit the attributes and operations of theparent class.
Button
ZoneButtonCancelButton
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 37/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 40
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, whereeach subsystem is modeled as a package.
Account
CustomerBank
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 38/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 41
Object Modeling in Practice
Class Identification: Name of Class, Attributes and Methods
Is Foo the right name?
Foo
Amount
CustomerId
Deposit()
Withdraw()GetBalance()
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 39/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 42
Object Modeling in Practice: Brainstorming
Foo
Amount
CustomerId
Deposit()
Withdraw()GetBalance()
Account
Amount
CustomerId
Deposit()Withdraw()GetBalance()Is Foo the right name?
“Dada”
Amount
CustomerId
Deposit()
Withdraw()GetBalance()
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 40/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 43
Object Modeling in Practice: More classes
Account
Amount
Deposit()Withdraw()GetBalance()
Customer
Name
CustomerId
CustomerIdAccountIdBank
Name
1) Find New Classes
2) Review Names, Attributes and Methods
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 41/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 44
Object Modeling in Practice: Associations
Account
Amount
Deposit()Withdraw()GetBalance()
Customer
Name
CustomerId
CustomerIdAccountIdAccountIdBank
Name
1) Find New Classes
2) Review Names, Attributes and Methods
3) Find Associations between Classes
owns
4) Label the generic assocations
6) Review associations
*2
*?
has
5) Determine the multiplicity of the assocations
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 42/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 45
Practice Object Modeling: Find Taxonomies
SavingsAccount
Withdraw()
CheckingAccount
Withdraw()
MortgageAccount
Withdraw()
Account
Amount
Deposit()Withdraw()GetBalance()
CustomerIdAccountIdAccountId
Customer
Name
CustomerId()
Has*Bank
Name*
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 43/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 46
Practice Object Modeling: Simplify, Organize
SavingsAccount
Withdraw()
CheckingAccount
Withdraw()
MortgageAccount
Withdraw()
Account
Amount
Deposit()Withdraw()GetBalance()
CustomerIdAccountIdAccountId
Show Taxonomies
separately
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 44/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 47
Practice Object Modeling: Simplify, Organize
Customer
Name
CustomerId()
Account
Amount
Deposit()Withdraw()GetBalance()
CustomerIdAccountIdAccountId
Bank
Name Has**
Use the 7+-2 heuristics
or better 5+-2!
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 45/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 48
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 byrectangles. Actors by sticky figures
♦ Lifelines are represented by dashedlines
♦ Messages are represented by arrows
♦ Activations are represented by narrowrectangles.
selectZone()
pickupChange()
pickUpTicket()
insertCoins()
TicketMachinePassenger
Focus oncontrol flow
Messages ->Operations on
participating Object
zone2price
selectZone()
insertCoins()
pickupChange()
pickUpTicket()
TicketMachine
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 46/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 49
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 resultsfrom a message
Passenger
selectZone()
ZoneButton TarifSchedule Display
lookupPrice(selection)
displayPrice(price)
price
Dataflow
*continued on next slide$$$
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 47/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 50
Sequence Diagrams: Iteration & Condition
♦ Iteration is denoted by a * preceding the message name
♦ Condition is denoted by boolean expression in [ ] before the messagename
Passenger ChangeProcessor
insertChange(coin)
CoinIdentifier Display CoinDrop
displayPrice(owedAmount)
lookupCoin(coin)
price
[owedAmount<0] returnChange(-owedAmount)
Iteration
Condition
*continued on next slide$$$
…continued from previous slide...
*
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 48/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 51
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 endof the useful life of an object.
Passenger ChangeProcessor
…continued from previous slide...
Ticket
createTicket(selection)
free()
Creation of Ticket
Destruction of Ticket
print()
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 49/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 52
Sequence Diagram Properties
♦
UML sequence diagram represent behavior in terms ofinteractions
♦ Useful to identify or find missing objects
♦ Time consuming to build, but worth the investment
♦
Complement the class diagrams (which represent structure).
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 50/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 53
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 asystem
Handle
Incident
Document
Incident
Archive
Incident
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 51/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 54
Activity Diagrams allow to model Decisions
OpenIncident
Notify
Police Chief
NotifyFire Chief
AllocateResources
[fire & highPriority]
[not fire & highPriority]
[lowPriority]
Decision
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 52/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 55
Activity Diagrams can model Concurrency
♦
Synchronization of multiple activities♦ Splitting the flow of control into multiple threads
OpenIncident
Allocate
Resources
CoordinateResources
DocumentIncident
ArchiveIncident
SynchronizationSplitting
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 53/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 56
Activity Diagrams: Grouping of Activities
♦
Activities may be grouped into swimlanes to denote the objector subsystem that implements the activities.
OpenIncident
AllocateResources
CoordinateResources
DocumentIncident
ArchiveIncident
Dispatcher
FieldOfficer
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 54/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 57
Activity Diagram vs. Statechart Diagram
HandleIncident
DocumentIncident
ArchiveIncident
Active Inactive Closed Archived
Incident-
Handled
Incident-
DocumentedIncident-
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)
TriggerlesstransitionCompletion of activity
causes state transition
Event causesstate transition
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 55/56
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 58
UML Summary
♦ UML provides a wide variety of notations for representingmany 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 activitydiagrams
7/23/2019 Ch02lect1 UD (1)
http://slidepdf.com/reader/full/ch02lect1-ud-1 56/56
Additional References
♦ Martin Fowler
UML Distilled: A Brief Guide to the Standard Object ModelingLanguage, 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, …