SlideShare une entreprise Scribd logo
1  sur  65
UsingUML,Patterns,andJava
Object-OrientedSoftwareEngineering Chapter 2,
Modeling with UML
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
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 the
model.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4
Example: street map
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 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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6
Systems, Models and Views
♦ A model is an abstraction describing a subset of a system
♦ A view depicts selected aspects of a model
♦ A notation is a set of graphical or textual rules for depicting views
♦ Views and models of a single system may overlap each other
Examples:
♦ System: Aircraft
♦ Models: Flight simulator, scale model
♦ Views: All blueprints, electrical wiring, fuel system
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7
Systems, Models and Views
System
View 1
Model 2
View 2
View 3
Model 1
Aircraft
Flightsimulator
Scale Model
Blueprints
Electrical
Wiring
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8
Models, Views and Systems (UML)
System Model View
**
Depicted byDescribed by
Airplane: System
Blueprints: View Fuel System: View Electrical Wiring: View
Scale Model: Model Flight Simulator: Model
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10
Object-oriented Modeling
Application Domain
(Phenomena)
Solution Domain
(Phenomena)
System Model (Concepts) System Model (Concepts)
Aircraft TrafficController
FlightPlanAirport
MapDisplay
FlightPlanDatabase
Summary
Display
TrafficControl
TrafficControl
UML
Package
(Analysis) (Design)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11
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)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12
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://www.ephorie.de/hindle_pareto-prinzip.htm
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13
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
♦ Statechart diagrams
 Describe the dynamic behavior of an individual object
♦ Activity diagrams
 Describe the dynamic behavior of a system, in particular the
workflow.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15
UML first pass: Use case diagrams
Use case diagrams represent the functionality of the system
from user’s point of view
Actor.
Use Case
System boundary
Classifier
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16
Historical Remark: UML 1 used packages
WatchUser
Actor
Use casePackage
Watch
Use case diagrams represent the functionality of the system
from user’s point of view
ReadTime
SetTime
ChangeBattery
WatchRepairPerson
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17
UML first pass: Class diagrams
Class
Association
Multiplicity
Class diagrams represent the structure of the system
2
1 1
1
1
1
1
2
SimpleWatch
Display Battery TimePushButton
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 18
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
Class
Association
Multiplicity
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 19
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()
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20
UML first pass: Statechart diagrams
State
Initial state
Final state
Transition
Event
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22
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.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23
UML Basic Notation Summary
♦ UML provides a wide variety of notations for modeling many
aspects of software systems
♦ Today we concentrated on a few notations:
 Functional model: Use case diagram
 Object model: Class diagram
 Dynamic model: Sequence diagrams, statechart
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24
Outline of this Class
♦ 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
♦ Statechart diagrams
 Describe the dynamic behavior of an individual object
♦ Activity diagrams
 Describe the dynamic behavior of a system, in particular the
workflow.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25
UML Basic Notation: First Summary
♦ UML provides a wide variety of notations for modeling many
aspects of software systems
♦ In the first lecture we concentrated on:
 Functional model: Use case diagram
 Object model: Class diagram
 Dynamic model: Sequence diagrams, statechart
♦ Now we go into a little bit more detail…
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 27
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29
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.
Passenger
PurchaseTicket
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30
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.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31
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>>
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32
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>>
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34
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
The class name is the only mandatory information
Each attribute has a type
Each operation has a signature
Type
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 35
Instances
♦ An instance represents a phenomenon
♦ The attributes are represented with their values
♦ The name of an instance is underlined
♦ The name can contain only the class name of the instance (anonymous
instance)
zone2price = {
{‘1’, 0.20},
{‘2’, 0.40},
{‘3’, 0.60}}
tarif2006:TarifSchedule
zone2price = {
{‘1’, 0.20},
{‘2’, 0.40},
{‘3’, 0.60}}
:TarifSchedule
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36
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”).
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 37
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.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 38
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 39
Many-to-Many Associations
StockExchange
Company
tickerSymbol**
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 40
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 41
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
tickerSymbolLists
**
Associations
are mapped to
Attributes!
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 42
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 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”)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 43
Qualifiers
♦ Qualifiers can be used to reduce the multiplicity of an
association
Directory
File
filename
Without qualification
1 *
With qualification
0..1
Directory File
1
filename
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 44
Qualification: Another Example
*StockExchange
CompanyLists
*tickerSymbol
1
StockExchange
Company
tickerSymbol
Lists
**
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 45
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
ZoneButtonCancelButton
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 46
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
CustomerBank
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 47
Object Modeling in Practice
Class Identification: Name of Class, Attributes and Methods
Is Foo the right name?
Foo
Amount
CustomerId
Deposit()
Withdraw()
GetBalance()
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 48
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()
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 49
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 50
Object Modeling in Practice: Associations
Account
Amount
Deposit()
Withdraw()
GetBalance()
Customer
Name
CustomerId
CustomerIdAccountId
AccountIdBank
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 51
Practice Object Modeling: Find Taxonomies
Savings
Account
Withdraw()
Checking
Account
Withdraw()
Mortgage
Account
Withdraw()
Account
Amount
Deposit()
Withdraw()
GetBalance()
CustomerIdAccountId
AccountId
Customer
Name
CustomerId()
Has*
Bank
Name
*
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 52
Practice Object Modeling: Simplify, Organize
Savings
Account
Withdraw()
Checking
Account
Withdraw()
Mortgage
Account
Withdraw()
Account
Amount
Deposit()
Withdraw()
GetBalance()
CustomerIdAccountId
AccountId
Show Taxonomies
separately
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 53
Practice Object Modeling: Simplify, Organize
Customer
Name
CustomerId()
Account
Amount
Deposit()
Withdraw()
GetBalance()
CustomerIdAccountId
AccountId
Bank
Name Has**
Use the 7+-2 heuristics
or better 5+-2!
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 54
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 55
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
Dataflow
…continued on next slide...
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 56
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)
Iteration
Condition
…continued on next slide...
…continued from previous slide...
*
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 57
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()
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 58
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).
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 59
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
Handle
Incident
Document
Incident
Archive
Incident
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 60
Activity Diagrams allow to model Decisions
Open
Incident
Notify
Police Chief
Notify
Fire Chief
Allocate
Resources
[fire & highPriority]
[not fire & highPriority]
[lowPriority]
Decision
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 61
Activity Diagrams can model Concurrency
♦ Synchronization of multiple activities
♦ Splitting the flow of control into multiple threads
Open
Incident
Allocate
Resources
Coordinate
Resources
Document
Incident
Archive
Incident
SynchronizationSplitting
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 62
Activity Diagrams: Grouping of Activities
♦ Activities may be grouped into swimlanes to denote the object
or subsystem that implements the activities.
Open
Incident
Allocate
Resources
Coordinate
Resources
Document
Incident
Archive
Incident
Dispatcher
FieldOfficer
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 63
Activity Diagram vs. Statechart Diagram
Handle
Incident
Document
Incident
Archive
Incident
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)
Triggerless
transitionCompletion of activity
causes state transition
Event causes
state transition
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 64
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
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 65
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, …

Contenu connexe

Tendances

UML and Software Modeling Tools.pptx
UML and Software Modeling Tools.pptxUML and Software Modeling Tools.pptx
UML and Software Modeling Tools.pptxNwabueze Obioma
 
What Is DevOps?
What Is DevOps?What Is DevOps?
What Is DevOps?Soumya De
 
Agile software development
Agile software developmentAgile software development
Agile software developmentRajesh Piryani
 
Uml with detail
Uml with detailUml with detail
Uml with detailHamza Khan
 
Software reliability engineering
Software reliability engineeringSoftware reliability engineering
Software reliability engineeringMark Turner CRP
 
Requirement Elicitation and Analysis.pptx
Requirement Elicitation and Analysis.pptxRequirement Elicitation and Analysis.pptx
Requirement Elicitation and Analysis.pptxRojipRai
 
Ch9-Software Engineering 9
Ch9-Software Engineering 9Ch9-Software Engineering 9
Ch9-Software Engineering 9Ian Sommerville
 
Golden Rules of User Experience Design - Theo Mandel, Ph.D. (UPDATED)
Golden Rules of  User Experience Design - Theo Mandel, Ph.D. (UPDATED)Golden Rules of  User Experience Design - Theo Mandel, Ph.D. (UPDATED)
Golden Rules of User Experience Design - Theo Mandel, Ph.D. (UPDATED)Theo Mandel, PhD
 
Software Engineering - chp3- design
Software Engineering - chp3- designSoftware Engineering - chp3- design
Software Engineering - chp3- designLilia Sfaxi
 
Ian Sommerville, Software Engineering, 9th Edition Ch 4
Ian Sommerville,  Software Engineering, 9th Edition Ch 4Ian Sommerville,  Software Engineering, 9th Edition Ch 4
Ian Sommerville, Software Engineering, 9th Edition Ch 4Mohammed Romi
 
Engineering Software Products: 10. Devops and code management
Engineering Software Products: 10. Devops and code managementEngineering Software Products: 10. Devops and code management
Engineering Software Products: 10. Devops and code managementsoftware-engineering-book
 
Advanced SQL - Database Access from Programming Languages
Advanced SQL - Database Access  from Programming LanguagesAdvanced SQL - Database Access  from Programming Languages
Advanced SQL - Database Access from Programming LanguagesS.Shayan Daneshvar
 
McCall Software Quality Model in Software Quality Assurance
McCall Software Quality Model in Software Quality Assurance McCall Software Quality Model in Software Quality Assurance
McCall Software Quality Model in Software Quality Assurance sundas Shabbir
 

Tendances (20)

Software Architecture
Software ArchitectureSoftware Architecture
Software Architecture
 
Ch13 security engineering
Ch13 security engineeringCh13 security engineering
Ch13 security engineering
 
UML and Software Modeling Tools.pptx
UML and Software Modeling Tools.pptxUML and Software Modeling Tools.pptx
UML and Software Modeling Tools.pptx
 
Ch23 project planning
Ch23 project planningCh23 project planning
Ch23 project planning
 
What Is DevOps?
What Is DevOps?What Is DevOps?
What Is DevOps?
 
Agile software development
Agile software developmentAgile software development
Agile software development
 
Uml with detail
Uml with detailUml with detail
Uml with detail
 
Software reliability engineering
Software reliability engineeringSoftware reliability engineering
Software reliability engineering
 
The Modern Software Architect
The Modern Software ArchitectThe Modern Software Architect
The Modern Software Architect
 
Requirement Elicitation and Analysis.pptx
Requirement Elicitation and Analysis.pptxRequirement Elicitation and Analysis.pptx
Requirement Elicitation and Analysis.pptx
 
Ch9-Software Engineering 9
Ch9-Software Engineering 9Ch9-Software Engineering 9
Ch9-Software Engineering 9
 
Golden Rules of User Experience Design - Theo Mandel, Ph.D. (UPDATED)
Golden Rules of  User Experience Design - Theo Mandel, Ph.D. (UPDATED)Golden Rules of  User Experience Design - Theo Mandel, Ph.D. (UPDATED)
Golden Rules of User Experience Design - Theo Mandel, Ph.D. (UPDATED)
 
Ch04lect1 ud
Ch04lect1 udCh04lect1 ud
Ch04lect1 ud
 
Ch9 evolution
Ch9 evolutionCh9 evolution
Ch9 evolution
 
Software Engineering - chp3- design
Software Engineering - chp3- designSoftware Engineering - chp3- design
Software Engineering - chp3- design
 
Ian Sommerville, Software Engineering, 9th Edition Ch 4
Ian Sommerville,  Software Engineering, 9th Edition Ch 4Ian Sommerville,  Software Engineering, 9th Edition Ch 4
Ian Sommerville, Software Engineering, 9th Edition Ch 4
 
Engineering Software Products: 10. Devops and code management
Engineering Software Products: 10. Devops and code managementEngineering Software Products: 10. Devops and code management
Engineering Software Products: 10. Devops and code management
 
Presentation on uml
Presentation on umlPresentation on uml
Presentation on uml
 
Advanced SQL - Database Access from Programming Languages
Advanced SQL - Database Access  from Programming LanguagesAdvanced SQL - Database Access  from Programming Languages
Advanced SQL - Database Access from Programming Languages
 
McCall Software Quality Model in Software Quality Assurance
McCall Software Quality Model in Software Quality Assurance McCall Software Quality Model in Software Quality Assurance
McCall Software Quality Model in Software Quality Assurance
 

En vedette

ASP.NET System design 2
ASP.NET System design 2ASP.NET System design 2
ASP.NET System design 2Sisir Ghosh
 
Abbott's Textual Analysis : Software Engineering 2
Abbott's Textual Analysis : Software Engineering 2Abbott's Textual Analysis : Software Engineering 2
Abbott's Textual Analysis : Software Engineering 2wahab13
 
Object Modeling with UML: Behavioral Modeling
Object Modeling with UML: Behavioral ModelingObject Modeling with UML: Behavioral Modeling
Object Modeling with UML: Behavioral Modelingelliando dias
 
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...Isuru Perera
 

En vedette (20)

Notacion uml
Notacion umlNotacion uml
Notacion uml
 
Ch03lect1 ud
Ch03lect1 udCh03lect1 ud
Ch03lect1 ud
 
Ch05lect1 ud
Ch05lect1 udCh05lect1 ud
Ch05lect1 ud
 
Ch03lect2 ud
Ch03lect2 udCh03lect2 ud
Ch03lect2 ud
 
Ch07lect1 ud
Ch07lect1 udCh07lect1 ud
Ch07lect1 ud
 
Ch09lect2 ud
Ch09lect2 udCh09lect2 ud
Ch09lect2 ud
 
Ch08lect2 ud
Ch08lect2 udCh08lect2 ud
Ch08lect2 ud
 
Ch08lect1 ud
Ch08lect1 udCh08lect1 ud
Ch08lect1 ud
 
Ch09lect1 ud
Ch09lect1 udCh09lect1 ud
Ch09lect1 ud
 
Ch08lect3 ud
Ch08lect3 udCh08lect3 ud
Ch08lect3 ud
 
Ch01lect1 ud
Ch01lect1 udCh01lect1 ud
Ch01lect1 ud
 
ASP.NET System design 2
ASP.NET System design 2ASP.NET System design 2
ASP.NET System design 2
 
Ch10lect1 ud
Ch10lect1 udCh10lect1 ud
Ch10lect1 ud
 
Ch10lect2 ud
Ch10lect2 udCh10lect2 ud
Ch10lect2 ud
 
Ch11lect1 ud
Ch11lect1 udCh11lect1 ud
Ch11lect1 ud
 
Ch05lect2 ud
Ch05lect2 udCh05lect2 ud
Ch05lect2 ud
 
Abbott's Textual Analysis : Software Engineering 2
Abbott's Textual Analysis : Software Engineering 2Abbott's Textual Analysis : Software Engineering 2
Abbott's Textual Analysis : Software Engineering 2
 
organization charts....rules
organization charts....rulesorganization charts....rules
organization charts....rules
 
Object Modeling with UML: Behavioral Modeling
Object Modeling with UML: Behavioral ModelingObject Modeling with UML: Behavioral Modeling
Object Modeling with UML: Behavioral Modeling
 
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
 

Similaire à Ch02lect1 ud

ch02lect1.ppt learning education for all students
ch02lect1.ppt learning education for all studentsch02lect1.ppt learning education for all students
ch02lect1.ppt learning education for all studentstalldesalegn
 
07 - Design and Implementation.pptx
07 - Design and Implementation.pptx07 - Design and Implementation.pptx
07 - Design and Implementation.pptxssuser13a155
 
Software Engineering Lec 2
Software Engineering Lec 2Software Engineering Lec 2
Software Engineering Lec 2Taymoor Nazmy
 
Introduction To Uml
Introduction To UmlIntroduction To Uml
Introduction To Umlguest514814
 
03 ooad-uml 03
03 ooad-uml 0303 ooad-uml 03
03 ooad-uml 03PujiHst
 
Introducing Uml And Development Process
Introducing Uml And Development ProcessIntroducing Uml And Development Process
Introducing Uml And Development ProcessTerry Cho
 
PhD Core Paper Unit 5 _Part 1 Software Design and UML Use Case Modeling.pdf
PhD Core Paper Unit 5 _Part 1 Software Design and UML Use Case Modeling.pdfPhD Core Paper Unit 5 _Part 1 Software Design and UML Use Case Modeling.pdf
PhD Core Paper Unit 5 _Part 1 Software Design and UML Use Case Modeling.pdfJAYANTHIKANNAN8
 
Software Engineering - Ch8
Software Engineering - Ch8Software Engineering - Ch8
Software Engineering - Ch8Siddharth Ayer
 
System Modelling
System ModellingSystem Modelling
System ModellingIanBriton
 
Software Engineering Tools and Practices.pdf
Software Engineering Tools and Practices.pdfSoftware Engineering Tools and Practices.pdf
Software Engineering Tools and Practices.pdfMeagGhn
 
Object Oriented Analysis and Design with UML2 part1
Object Oriented Analysis and Design with UML2 part1Object Oriented Analysis and Design with UML2 part1
Object Oriented Analysis and Design with UML2 part1Haitham Raik
 
4.o o design tools=uml -_lecture 4
4.o o design tools=uml -_lecture 44.o o design tools=uml -_lecture 4
4.o o design tools=uml -_lecture 4Warui Maina
 

Similaire à Ch02lect1 ud (20)

ch02lect1.ppt
ch02lect1.pptch02lect1.ppt
ch02lect1.ppt
 
ch02lect1.ppt learning education for all students
ch02lect1.ppt learning education for all studentsch02lect1.ppt learning education for all students
ch02lect1.ppt learning education for all students
 
ch01lect1.ppt
ch01lect1.pptch01lect1.ppt
ch01lect1.ppt
 
ch2lect.ppt
ch2lect.pptch2lect.ppt
ch2lect.ppt
 
Chapter1
Chapter1Chapter1
Chapter1
 
ch04lect1.ppt
ch04lect1.pptch04lect1.ppt
ch04lect1.ppt
 
02_IT4557.pptx
02_IT4557.pptx02_IT4557.pptx
02_IT4557.pptx
 
07 - Design and Implementation.pptx
07 - Design and Implementation.pptx07 - Design and Implementation.pptx
07 - Design and Implementation.pptx
 
Software Engineering Lec 2
Software Engineering Lec 2Software Engineering Lec 2
Software Engineering Lec 2
 
Introduction To Uml
Introduction To UmlIntroduction To Uml
Introduction To Uml
 
03 ooad-uml 03
03 ooad-uml 0303 ooad-uml 03
03 ooad-uml 03
 
Introducing Uml And Development Process
Introducing Uml And Development ProcessIntroducing Uml And Development Process
Introducing Uml And Development Process
 
PhD Core Paper Unit 5 _Part 1 Software Design and UML Use Case Modeling.pdf
PhD Core Paper Unit 5 _Part 1 Software Design and UML Use Case Modeling.pdfPhD Core Paper Unit 5 _Part 1 Software Design and UML Use Case Modeling.pdf
PhD Core Paper Unit 5 _Part 1 Software Design and UML Use Case Modeling.pdf
 
Case stydy cs701
Case stydy cs701 Case stydy cs701
Case stydy cs701
 
Software Engineering - Ch8
Software Engineering - Ch8Software Engineering - Ch8
Software Engineering - Ch8
 
System Modelling
System ModellingSystem Modelling
System Modelling
 
Software Engineering Tools and Practices.pdf
Software Engineering Tools and Practices.pdfSoftware Engineering Tools and Practices.pdf
Software Engineering Tools and Practices.pdf
 
Object Oriented Analysis and Design with UML2 part1
Object Oriented Analysis and Design with UML2 part1Object Oriented Analysis and Design with UML2 part1
Object Oriented Analysis and Design with UML2 part1
 
Ch14
Ch14Ch14
Ch14
 
4.o o design tools=uml -_lecture 4
4.o o design tools=uml -_lecture 44.o o design tools=uml -_lecture 4
4.o o design tools=uml -_lecture 4
 

Ch02lect1 ud

  • 2. 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
  • 3. 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 the model.
  • 4. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4 Example: street map
  • 5. 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 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. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6 Systems, Models and Views ♦ A model is an abstraction describing a subset of a system ♦ A view depicts selected aspects of a model ♦ A notation is a set of graphical or textual rules for depicting views ♦ Views and models of a single system may overlap each other Examples: ♦ System: Aircraft ♦ Models: Flight simulator, scale model ♦ Views: All blueprints, electrical wiring, fuel system
  • 7. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7 Systems, Models and Views System View 1 Model 2 View 2 View 3 Model 1 Aircraft Flightsimulator Scale Model Blueprints Electrical Wiring
  • 8. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8 Models, Views and Systems (UML) System Model View ** Depicted byDescribed by Airplane: System Blueprints: View Fuel System: View Electrical Wiring: View Scale Model: Model Flight Simulator: Model
  • 9. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9 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
  • 10. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10 Object-oriented Modeling Application Domain (Phenomena) Solution Domain (Phenomena) System Model (Concepts) System Model (Concepts) Aircraft TrafficController FlightPlanAirport MapDisplay FlightPlanDatabase Summary Display TrafficControl TrafficControl UML Package (Analysis) (Design)
  • 11. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11 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)
  • 12. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12 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://www.ephorie.de/hindle_pareto-prinzip.htm
  • 13. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13 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 ♦ Statechart diagrams  Describe the dynamic behavior of an individual object ♦ Activity diagrams  Describe the dynamic behavior of a system, in particular the workflow.
  • 14. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14 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
  • 15. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15 UML first pass: Use case diagrams Use case diagrams represent the functionality of the system from user’s point of view Actor. Use Case System boundary Classifier
  • 16. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16 Historical Remark: UML 1 used packages WatchUser Actor Use casePackage Watch Use case diagrams represent the functionality of the system from user’s point of view ReadTime SetTime ChangeBattery WatchRepairPerson
  • 17. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17 UML first pass: Class diagrams Class Association Multiplicity Class diagrams represent the structure of the system 2 1 1 1 1 1 1 2 SimpleWatch Display Battery TimePushButton
  • 18. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 18 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 Class Association Multiplicity
  • 19. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 19 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()
  • 20. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20 UML first pass: Statechart diagrams State Initial state Final state Transition Event 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
  • 21. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21 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
  • 22. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22 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.
  • 23. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23 UML Basic Notation Summary ♦ UML provides a wide variety of notations for modeling many aspects of software systems ♦ Today we concentrated on a few notations:  Functional model: Use case diagram  Object model: Class diagram  Dynamic model: Sequence diagrams, statechart
  • 24. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24 Outline of this Class ♦ 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 ♦ Statechart diagrams  Describe the dynamic behavior of an individual object ♦ Activity diagrams  Describe the dynamic behavior of a system, in particular the workflow.
  • 25. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25 UML Basic Notation: First Summary ♦ UML provides a wide variety of notations for modeling many aspects of software systems ♦ In the first lecture we concentrated on:  Functional model: Use case diagram  Object model: Class diagram  Dynamic model: Sequence diagrams, statechart ♦ Now we go into a little bit more detail…
  • 26. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26 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
  • 27. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 27 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
  • 28. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28 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
  • 29. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29 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. Passenger PurchaseTicket
  • 30. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30 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.
  • 31. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31 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>>
  • 32. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32 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>>
  • 33. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33 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
  • 34. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34 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 The class name is the only mandatory information Each attribute has a type Each operation has a signature Type
  • 35. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 35 Instances ♦ An instance represents a phenomenon ♦ The attributes are represented with their values ♦ The name of an instance is underlined ♦ The name can contain only the class name of the instance (anonymous instance) zone2price = { {‘1’, 0.20}, {‘2’, 0.40}, {‘3’, 0.60}} tarif2006:TarifSchedule zone2price = { {‘1’, 0.20}, {‘2’, 0.40}, {‘3’, 0.60}} :TarifSchedule
  • 36. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36 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”).
  • 37. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 37 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.
  • 38. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 38 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
  • 39. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 39 Many-to-Many Associations StockExchange Company tickerSymbol**
  • 40. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 40 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
  • 41. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 41 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 tickerSymbolLists ** Associations are mapped to Attributes!
  • 42. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 42 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 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”)
  • 43. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 43 Qualifiers ♦ Qualifiers can be used to reduce the multiplicity of an association Directory File filename Without qualification 1 * With qualification 0..1 Directory File 1 filename
  • 44. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 44 Qualification: Another Example *StockExchange CompanyLists *tickerSymbol 1 StockExchange Company tickerSymbol Lists **
  • 45. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 45 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 ZoneButtonCancelButton
  • 46. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 46 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 CustomerBank
  • 47. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 47 Object Modeling in Practice Class Identification: Name of Class, Attributes and Methods Is Foo the right name? Foo Amount CustomerId Deposit() Withdraw() GetBalance()
  • 48. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 48 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()
  • 49. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 49 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
  • 50. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 50 Object Modeling in Practice: Associations Account Amount Deposit() Withdraw() GetBalance() Customer Name CustomerId CustomerIdAccountId AccountIdBank 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
  • 51. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 51 Practice Object Modeling: Find Taxonomies Savings Account Withdraw() Checking Account Withdraw() Mortgage Account Withdraw() Account Amount Deposit() Withdraw() GetBalance() CustomerIdAccountId AccountId Customer Name CustomerId() Has* Bank Name *
  • 52. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 52 Practice Object Modeling: Simplify, Organize Savings Account Withdraw() Checking Account Withdraw() Mortgage Account Withdraw() Account Amount Deposit() Withdraw() GetBalance() CustomerIdAccountId AccountId Show Taxonomies separately
  • 53. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 53 Practice Object Modeling: Simplify, Organize Customer Name CustomerId() Account Amount Deposit() Withdraw() GetBalance() CustomerIdAccountId AccountId Bank Name Has** Use the 7+-2 heuristics or better 5+-2!
  • 54. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 54 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
  • 55. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 55 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 Dataflow …continued on next slide...
  • 56. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 56 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) Iteration Condition …continued on next slide... …continued from previous slide... *
  • 57. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 57 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()
  • 58. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 58 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).
  • 59. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 59 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 Handle Incident Document Incident Archive Incident
  • 60. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 60 Activity Diagrams allow to model Decisions Open Incident Notify Police Chief Notify Fire Chief Allocate Resources [fire & highPriority] [not fire & highPriority] [lowPriority] Decision
  • 61. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 61 Activity Diagrams can model Concurrency ♦ Synchronization of multiple activities ♦ Splitting the flow of control into multiple threads Open Incident Allocate Resources Coordinate Resources Document Incident Archive Incident SynchronizationSplitting
  • 62. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 62 Activity Diagrams: Grouping of Activities ♦ Activities may be grouped into swimlanes to denote the object or subsystem that implements the activities. Open Incident Allocate Resources Coordinate Resources Document Incident Archive Incident Dispatcher FieldOfficer
  • 63. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 63 Activity Diagram vs. Statechart Diagram Handle Incident Document Incident Archive Incident 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) Triggerless transitionCompletion of activity causes state transition Event causes state transition
  • 64. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 64 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
  • 65. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 65 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, …

Notes de l'éditeur

  1. Statechart diagrams Describe the dynamic behavior of an individual object (essentially a finite state automaton) Activity Diagrams Model the dynamic behavior of a system, in particular the workflow (essentially a flowchart)
  2. Represent behavior of single objects with interesting dynamic behavior in terms of states and transitions The behavior of the single object Watch, for example, has several different interesting states, BlinkHours, BlinkMinutes, BlinkSeconds, Because in each state pressing a button or two yields a different result.
  3. In particular, in the lecture on System Design we introduced Deployment Diagrams, in the lecture on Testing we introduce Profiles. There is also a language to constrain the systems that can be instantiated from models. The language that has been designed to constain UML models is called OCL (Object constraint language) Introduced in lecture on Object Design
  4. Powerful, but complex language Warning: Can also be misused to generate unreadable models Warning: Can be misunderstood when using too many exotic features
  5. We provided already a basic overview of the notations: Use case diagrams Class diagrams Sequence diagrams, statechart diagrams We will now go int more detail and cover two additional notations as well, sequence diagrams and activity diagrams
  6. Powerful, but complex language Can be misused to generate unreadable models Can be misunderstood when using too many exotic features
  7. Question: Anything missing? Answer: Exceptional cases! Use cases represent functionality of the system All use cases need to be described for the model to be useful Use case diagrams are useful as an index into the use cases The Textual Use case descriptions provide meat of model, not the use case diagrams.
  8. What is the difference between an actor, a class and an instance?
  9. A stock exchange lists many companies each of them uniquely identifed by a ticker symbol used at that stock exchange. A company can be listed on more than one stock exchange, using the same ticker symbol. Mercedes Benz is an example for a company listed on more than one stock exchange: Frankfurt and NYSE. Does it have two different Ticker symbols? Something not clear here: What happens if the company cannot have the same ticker symbol on two different stock exchanges?
  10. Example for composition: Bill of Material
  11. In this case, filename is a qualifier attached to Directory
  12. Later we will also see how inheritance allows the reuse of solutions (implementation and specification inheritance)
  13. Packages are the grouping construct with
  14. Naming is important!
  15. There are two types of states: Action state: Cannot be decomposed any further Happens “instantaneously” with respect to the level of abstraction used in the model Activity state: Can be decomposed further The activity is modeled by another activity diagram
  16. Statechart Diagram for Incident (similar to Mealy Automaton) Activity Diagram for Incident (similar to Moore Automaton)
  17. Also: - Together Designer 2006 for Eclipse - Together Designer 2005, for Microsoftィ Visual Studio.NET 2003 - Together Designer 2005, for JBuilderィ 2005