SlideShare a Scribd company logo
1 of 44
© SERG
Software Design (UML)
Software Design
Static Modeling using the
Unified Modeling Language
(UML)
Material based on
[Booch99, Rambaugh99, Jacobson99, Fowler97, Brown99]
Using
UML,
Patterns,
and
Java
Object-Oriented
Software
Engineering Chapter 2,
Modeling with UML
© SERG
Overview: modeling with UML
• What is modeling?
• What is UML?
• Use case diagrams
• Class diagrams
• Sequence diagrams
• Activity diagrams
© SERG
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.
© SERG
Example: street map
© SERG
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 mean for dealing with complexity
© SERG
What is UML?
• UML (Unified Modeling Language)
– An emerging standard for modeling object-oriented software.
– Resulted from the convergence of notations from three leading
object-oriented methods:
• OMT (James Rumbaugh) Object Modeling Technique
• OOSE (Ivar Jacobson) Object Oriented Software Engineering
• Booch (Grady Booch)
• Reference: “The Unified Modeling Language User Guide”, Addison
Wesley, 1999.
• Supported by several CASE tools
– Rational ROSE
– TogetherJ
© SERG
UML: First Pass
• You can model 80% of most problems by
using about 20 % UML
• We teach you those 20%
© SERG
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 actors and the system
and between objects of the system
• 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)
© SERG
UML first pass: Use case diagrams
WatchUser WatchRepairPerson
ReadTime
SetTime
ChangeBattery
Actor
Use case
Package
Watch
Use case diagrams represent the functionality of the system
from user’s point of view
© SERG
UML first pass: Class diagrams
1
2
push()
release()
1
1
blinkIdx
blinkSeconds()
blinkMinutes()
blinkHours()
stopBlinking()
referesh()
LCDDisplay
1
Time
now
1
Watch
Class
Association
Multiplicity
Attribute
Operations
state
PushButton
Class diagrams represent the structure of the system
© SERG
UML first pass: Sequence diagram
:LCDDisplay
blinkHours()
blinkMinutes()
refresh()
commitNewTime()
:Time
incrementMinutes()
stopBlinking()
:Watch
pressButton1(& 2)
pressButton2()
pressButtons1And2()
pressButton1()
:WatchUser
Object
Message
Activation
Sequence diagrams represent the behavior as interactions
Actor
Lifeline
© SERG
UML first pass: Statechart diagrams for objects with
interesting dynamic behavior
BlinkHours
BlinkMinutes
IncrementHrs
IncrementMin.
BlinkSeconds IncrementSec.
StopBlinking
[button1&2Pressed]
[button1Pressed]
[button2Pressed]
[button2Pressed]
[button2Pressed]
[button1Pressed]
[button1&2Pressed]
[button1&2Pressed]
State
Initial state
Final state
Transition
Event
Represent behavior as states and transitions
© SERG
Use Case Diagrams
• Used during requirements
elicitation to represent external
behavior
• Actors represent roles, that is, a
type of user of the system
• Use cases represent a sequence of
interaction for a type of
functionality
• The use case model is the set of
all use cases. It is a complete
description of the functionality of
the system and its environment
Passenger
PurchaseTicket
© SERG
Actors
• An actor models an external entity which
communicates with the system:
– User
– External system
– Physical environment
• An actor has a unique name and an optional
description.
• Examples:
– Passenger: A person in the train
– GPS satellite: Provides the system with GPS
coordinates
Passenger
© SERG
Use Case
A use case represents a class of
functionality provided by the system as
an event flow.
A use case consists of:
• Unique name
• Participating actors
• Entry conditions
• Flow of events
• Exit conditions
• Special requirements
PurchaseTicket
© SERG
Use Case Diagram: Example
Name: Purchase ticket
Participating actor: Passenger
Entry condition:
• Passenger standing in front of
ticket distributor.
• Passenger has sufficient
money to purchase ticket.
Exit condition:
• Passenger has ticket.
Event flow:
1. Passenger selects the number of
zones to be traveled.
2. Distributor displays the amount
due.
3. Passenger inserts money, of at
least the amount due.
4. Distributor returns change.
5. Distributor issues ticket.
Anything missing?
Exceptional cases!
© SERG
The <<extends>> Relationship
• <<extends>> relationships
represent exceptional or seldom
invoked cases.
• The exceptional event flows are
factored out of the main event
flow for clarity.
• Use cases representing
exceptional flows can extend
more than one use case.
• The direction of a <<extends>>
relationship is to the extended use
case
Passenger
PurchaseTicket
TimeOut
<<extends>>
NoChange
<<extends>>
OutOfOrder
<<extends>>
Cancel
<<extends>>
© SERG
The <<includes>> Relationship
• <<includes>> relationship
represents behavior that is
factored out of the 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 <<extends>>
relationships).
Passenger
PurchaseSingleTicket
PurchaseMultiCard
NoChange
<<extends>>
Cancel
<<extends>>
<<includes>>
CollectMoney
<<includes>>
© SERG
Use Case Diagrams: Summary
• Use case diagrams represent external
behavior
• Use case diagrams are useful as an index
into the use cases
• Use case descriptions provide meat of
model, not the use case diagrams.
• All use cases need to be described for the
model to be useful.
© SERG
Software Design (UML)
Class Operations
Person
name : String
address : Address
birthdate : Date
ssn : Id
eat
sleep
work
play
Operations describe the class behavior
and appear in the third compartment.
Class Name
Class Attributes
Class Operations
An attribute is a named property of a class that
describes the object being modeled.In the class
diagram, attributes appear in the second compartment
just below the name-compartment.
The name of the class is the only
required tag in the graphical
representation of a class. It always
appears in the top-most compartment.
© SERG
Software Design (UML)
Relationships
In UML, object interconnections (logical or physical), are
modeled as relationships.
There are three kinds of relationships in UML:
• dependencies
• generalizations
• associations
© SERG
Software Design (UML)
Dependency Relationships
CourseSchedule
add(c : Course)
remove(c : Course)
Course
A dependency indicates a semantic relationship between two or
more elements. The dependency from CourseSchedule to
Course exists because Course is used in both the add and
remove operations of CourseSchedule.
© SERG
Software Design (UML)
Generalization Relationships
Person
A generalization connects a subclass
to its superclass. It denotes an
inheritance of attributes and behavior
from the superclass to the subclass and
indicates a specialization in the subclass
of the more general superclass.
Student
© SERG
Software Design (UML)
Generalization Relationships (Cont’d)
Student
UML permits a class to inherit from multiple superclasses,
although some programming languages (e.g., Java) do not permit
multiple inheritance.
TeachingAssistant
Employee
© SERG
Software Design (UML)
Association Relationships
If two classes in a model need to communicate with each other,
there must be link between them.
An association denotes that link.
Instructor
Student
© SERG
Software Design (UML)
Association Relationships (Cont’d)
We can indicate the multiplicity of an association by adding
multiplicity adornments to the line denoting the association.
The example indicates that a Student has one or more
Instructors:
Instructor
Student
1..*
© SERG
Software Design (UML)
Association Relationships (Cont’d)
The example indicates that every Instructor has one or more
Students:
Instructor
Student
1..*
© SERG
Software Design (UML)
Association Relationships (Cont’d)
We can also indicate the behavior of an object in an association
(i.e., the role of an object) using rolenames.
Instructor
Student
1..*
1..*
learns from
teaches
© SERG
Software Design (UML)
Association Relationships (Cont’d)
We can also name the association.
Team
Student
membership
1..* 1..*
© SERG
Software Design (UML)
Association Relationships (Cont’d)
We can specify dual associations.
Team
Student
member of
1..*
president of
1 1..*
1..*
© SERG
Software Design (UML)
Association Relationships (Cont’d)
We can constrain the association relationship by defining the
navigability of the association. Here, a Router object requests
services from a DNS object by sending messages to (invoking
the operations of) the server. The direction of the association
indicates that the server has no knowledge of the Router.
Router DomainNameServer
© SERG
Software Design (UML)
Association Relationships (Cont’d)
A class can have a self association.
LinkedListNode
next
previous
© SERG
Software Design (UML)
Association Relationships (Cont’d)
We can model objects that contain other objects by way of
special associations called aggregations and compositions.
An aggregation specifies a whole-part relationship between an
aggregate (a whole) and a constituent part, where the part can
exist independently from the aggregate. Aggregations are
denoted by a hollow-diamond adornment on the association.
Car
Engine
Transmission
© SERG
Software Design (UML)
Association Relationships (Cont’d)
A composition indicates a strong ownership and coincident
lifetime of parts by the whole (i.e., they live and die as a
whole). Compositions are denoted by a filled-diamond
adornment on the association.
Window
Scrollbar
Titlebar
Menu
1
1
1
1
1
1 .. *
© SERG
Software Design (UML)
Software Design
Dynamic Modeling using the
Unified Modeling Language
(UML)
© SERG
Software Design (UML)
State Machine
An object must be in some specific state at any given time during
its lifecycle. An object transitions from one state to another as the
result of some event that affects it. You may create a state
diagram for any class, collaboration, operation, or use case in a
UML model .
There can be only one start state in a state diagram, but there may
be many intermediate and final states.
© SERG
Software Design (UML)
State Machine
start state final state
simple state
concurrent composite state
sequential composite state
© SERG
Software Design (UML)
State Machine
selecting
verifying
downloading
checking schedule
download course offerings
make a course selection
verify selection
check schedule
select another course
make a different selection
unscheduled
scheduled
sign schedule
© SERG
Software Design (UML)
Collaboration Diagram
A collaboration diagram emphasizes the relationship of the
objects that participate in an interaction. Unlike a sequence
diagram, you don’t have to show the lifeline of an object
explicitly in a collaboration diagram. The sequence of events are
indicated by sequence numbers preceding messages.
Object identifiers are of the form objectName : className, and
either the objectName or the className can be omitted, and the
placement of the colon indicates either an objectName: , or a
:className.
© SERG
Software Design (UML)
Collaboration Diagram
: Order Entry Window
: Order
: Order Line
:Delivery Item
: Stock Item
:Reorder Item
1: prepare()
2*: prepare() 3: check()
4: [check == true] remove()
6: new
7: [check == true] new
5: needToReorder()
[Fowler,97]
Self-Delegation
Object
Message
Sequence Number
© SERG
Software Design (UML)
Activity Diagram
An activity diagram is essentially a flowchart, showing the
flow of control from activity to activity.
Use activity diagrams to specify, construct, and document the
dynamics of a society of objects, or to model the flow of
control of an operation. Whereas interaction diagrams
emphasize the flow of control from object to object, activity
diagrams emphasize the flow of control from activity to
activity. An activity is an ongoing non-atomic execution
within a state machine.
- The UML User Guide, [Booch,99]
© SERG
Software Design (UML)
[Fowler,97]
Receive
Order
Authorize
Payment
Check
Line
Item
Cancel
Order
Assign to
Order
Reorder
Item
Dispatch
Order
[failed]
[succeeded] [in stock]
*
for each line
item on order
[need to
reorder]
[stock assigned to
all line items and
payment authorized]
Synchronization Condition
Multiple Trigger
© SERG
Software Design (UML)
References
[Booch99] Booch, Grady, James Rumbaugh, Ivar Jacobson,
The Unified Modeling Language User Guide, Addison Wesley, 1999
[Rambaugh99] Rumbaugh, James, Ivar Jacobson, Grady Booch, The Unified
Modeling Language Reference Manual, Addison Wesley, 1999
[Jacobson99] Jacobson, Ivar, Grady Booch, James Rumbaugh, The Unified
Software Development Process, Addison Wesley, 1999
[Fowler, 1997] Fowler, Martin, Kendall Scott, UML Distilled
(Applying the Standard Object Modeling Language),
Addison Wesley, 1997.
[Brown99] First draft of these slides were created by James Brown.

More Related Content

Similar to lecture 3.ppt

Similar to lecture 3.ppt (20)

Intro Uml
Intro UmlIntro Uml
Intro Uml
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
Case stydy cs701
Case stydy cs701 Case stydy cs701
Case stydy cs701
 
CASE Tools lab.ppt
CASE Tools lab.pptCASE Tools lab.ppt
CASE Tools lab.ppt
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering
 
uml.ppt
uml.pptuml.ppt
uml.ppt
 
M02 Uml Overview
M02 Uml OverviewM02 Uml Overview
M02 Uml Overview
 
Uml intro
Uml introUml intro
Uml intro
 
Uml
UmlUml
Uml
 
Uml
UmlUml
Uml
 
Uml
UmlUml
Uml
 
UML Design Document Training Learn UML .pptx
UML Design Document Training Learn UML .pptxUML Design Document Training Learn UML .pptx
UML Design Document Training Learn UML .pptx
 
Modeling software with UML
Modeling software with UMLModeling software with UML
Modeling software with UML
 
Cs8592 ooad unit 1
Cs8592 ooad unit 1Cs8592 ooad unit 1
Cs8592 ooad unit 1
 
Cs8592 ooad unit 1
Cs8592 ooad unit 1Cs8592 ooad unit 1
Cs8592 ooad unit 1
 
Uml Presentation
Uml PresentationUml Presentation
Uml Presentation
 
Lecture 3 cst205 cst281-oop
Lecture 3 cst205 cst281-oopLecture 3 cst205 cst281-oop
Lecture 3 cst205 cst281-oop
 
UML Basics
UML BasicsUML Basics
UML Basics
 
uml2-1214558329929112-8.ppt
uml2-1214558329929112-8.pptuml2-1214558329929112-8.ppt
uml2-1214558329929112-8.ppt
 
Darshan sem4 140703_ooad_2014 (diagrams)
Darshan sem4 140703_ooad_2014 (diagrams)Darshan sem4 140703_ooad_2014 (diagrams)
Darshan sem4 140703_ooad_2014 (diagrams)
 

Recently uploaded

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 

Recently uploaded (20)

2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 

lecture 3.ppt

  • 1. © SERG Software Design (UML) Software Design Static Modeling using the Unified Modeling Language (UML) Material based on [Booch99, Rambaugh99, Jacobson99, Fowler97, Brown99]
  • 3. © SERG Overview: modeling with UML • What is modeling? • What is UML? • Use case diagrams • Class diagrams • Sequence diagrams • Activity diagrams
  • 4. © SERG 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.
  • 6. © SERG 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 mean for dealing with complexity
  • 7. © SERG What is UML? • UML (Unified Modeling Language) – An emerging standard for modeling object-oriented software. – Resulted from the convergence of notations from three leading object-oriented methods: • OMT (James Rumbaugh) Object Modeling Technique • OOSE (Ivar Jacobson) Object Oriented Software Engineering • Booch (Grady Booch) • Reference: “The Unified Modeling Language User Guide”, Addison Wesley, 1999. • Supported by several CASE tools – Rational ROSE – TogetherJ
  • 8. © SERG UML: First Pass • You can model 80% of most problems by using about 20 % UML • We teach you those 20%
  • 9. © SERG 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 actors and the system and between objects of the system • 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)
  • 10. © SERG UML first pass: Use case diagrams WatchUser WatchRepairPerson ReadTime SetTime ChangeBattery Actor Use case Package Watch Use case diagrams represent the functionality of the system from user’s point of view
  • 11. © SERG UML first pass: Class diagrams 1 2 push() release() 1 1 blinkIdx blinkSeconds() blinkMinutes() blinkHours() stopBlinking() referesh() LCDDisplay 1 Time now 1 Watch Class Association Multiplicity Attribute Operations state PushButton Class diagrams represent the structure of the system
  • 12. © SERG UML first pass: Sequence diagram :LCDDisplay blinkHours() blinkMinutes() refresh() commitNewTime() :Time incrementMinutes() stopBlinking() :Watch pressButton1(& 2) pressButton2() pressButtons1And2() pressButton1() :WatchUser Object Message Activation Sequence diagrams represent the behavior as interactions Actor Lifeline
  • 13. © SERG UML first pass: Statechart diagrams for objects with interesting dynamic behavior BlinkHours BlinkMinutes IncrementHrs IncrementMin. BlinkSeconds IncrementSec. StopBlinking [button1&2Pressed] [button1Pressed] [button2Pressed] [button2Pressed] [button2Pressed] [button1Pressed] [button1&2Pressed] [button1&2Pressed] State Initial state Final state Transition Event Represent behavior as states and transitions
  • 14. © SERG Use Case Diagrams • Used during requirements elicitation to represent external behavior • Actors represent roles, that is, a type of user of the system • Use cases represent a sequence of interaction for a type of functionality • The use case model is the set of all use cases. It is a complete description of the functionality of the system and its environment Passenger PurchaseTicket
  • 15. © SERG Actors • An actor models an external entity which communicates with the system: – User – External system – Physical environment • An actor has a unique name and an optional description. • Examples: – Passenger: A person in the train – GPS satellite: Provides the system with GPS coordinates Passenger
  • 16. © SERG Use Case A use case represents a class of functionality provided by the system as an event flow. A use case consists of: • Unique name • Participating actors • Entry conditions • Flow of events • Exit conditions • Special requirements PurchaseTicket
  • 17. © SERG Use Case Diagram: Example Name: Purchase ticket Participating actor: Passenger Entry condition: • Passenger standing in front of ticket distributor. • Passenger has sufficient money to purchase ticket. Exit condition: • Passenger has ticket. Event flow: 1. Passenger selects the number of zones to be traveled. 2. Distributor displays the amount due. 3. Passenger inserts money, of at least the amount due. 4. Distributor returns change. 5. Distributor issues ticket. Anything missing? Exceptional cases!
  • 18. © SERG The <<extends>> Relationship • <<extends>> relationships represent exceptional or seldom invoked cases. • The exceptional event flows are factored out of the main event flow for clarity. • Use cases representing exceptional flows can extend more than one use case. • The direction of a <<extends>> relationship is to the extended use case Passenger PurchaseTicket TimeOut <<extends>> NoChange <<extends>> OutOfOrder <<extends>> Cancel <<extends>>
  • 19. © SERG The <<includes>> Relationship • <<includes>> relationship represents behavior that is factored out of the 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 <<extends>> relationships). Passenger PurchaseSingleTicket PurchaseMultiCard NoChange <<extends>> Cancel <<extends>> <<includes>> CollectMoney <<includes>>
  • 20. © SERG Use Case Diagrams: Summary • Use case diagrams represent external behavior • Use case diagrams are useful as an index into the use cases • Use case descriptions provide meat of model, not the use case diagrams. • All use cases need to be described for the model to be useful.
  • 21. © SERG Software Design (UML) Class Operations Person name : String address : Address birthdate : Date ssn : Id eat sleep work play Operations describe the class behavior and appear in the third compartment. Class Name Class Attributes Class Operations An attribute is a named property of a class that describes the object being modeled.In the class diagram, attributes appear in the second compartment just below the name-compartment. The name of the class is the only required tag in the graphical representation of a class. It always appears in the top-most compartment.
  • 22. © SERG Software Design (UML) Relationships In UML, object interconnections (logical or physical), are modeled as relationships. There are three kinds of relationships in UML: • dependencies • generalizations • associations
  • 23. © SERG Software Design (UML) Dependency Relationships CourseSchedule add(c : Course) remove(c : Course) Course A dependency indicates a semantic relationship between two or more elements. The dependency from CourseSchedule to Course exists because Course is used in both the add and remove operations of CourseSchedule.
  • 24. © SERG Software Design (UML) Generalization Relationships Person A generalization connects a subclass to its superclass. It denotes an inheritance of attributes and behavior from the superclass to the subclass and indicates a specialization in the subclass of the more general superclass. Student
  • 25. © SERG Software Design (UML) Generalization Relationships (Cont’d) Student UML permits a class to inherit from multiple superclasses, although some programming languages (e.g., Java) do not permit multiple inheritance. TeachingAssistant Employee
  • 26. © SERG Software Design (UML) Association Relationships If two classes in a model need to communicate with each other, there must be link between them. An association denotes that link. Instructor Student
  • 27. © SERG Software Design (UML) Association Relationships (Cont’d) We can indicate the multiplicity of an association by adding multiplicity adornments to the line denoting the association. The example indicates that a Student has one or more Instructors: Instructor Student 1..*
  • 28. © SERG Software Design (UML) Association Relationships (Cont’d) The example indicates that every Instructor has one or more Students: Instructor Student 1..*
  • 29. © SERG Software Design (UML) Association Relationships (Cont’d) We can also indicate the behavior of an object in an association (i.e., the role of an object) using rolenames. Instructor Student 1..* 1..* learns from teaches
  • 30. © SERG Software Design (UML) Association Relationships (Cont’d) We can also name the association. Team Student membership 1..* 1..*
  • 31. © SERG Software Design (UML) Association Relationships (Cont’d) We can specify dual associations. Team Student member of 1..* president of 1 1..* 1..*
  • 32. © SERG Software Design (UML) Association Relationships (Cont’d) We can constrain the association relationship by defining the navigability of the association. Here, a Router object requests services from a DNS object by sending messages to (invoking the operations of) the server. The direction of the association indicates that the server has no knowledge of the Router. Router DomainNameServer
  • 33. © SERG Software Design (UML) Association Relationships (Cont’d) A class can have a self association. LinkedListNode next previous
  • 34. © SERG Software Design (UML) Association Relationships (Cont’d) We can model objects that contain other objects by way of special associations called aggregations and compositions. An aggregation specifies a whole-part relationship between an aggregate (a whole) and a constituent part, where the part can exist independently from the aggregate. Aggregations are denoted by a hollow-diamond adornment on the association. Car Engine Transmission
  • 35. © SERG Software Design (UML) Association Relationships (Cont’d) A composition indicates a strong ownership and coincident lifetime of parts by the whole (i.e., they live and die as a whole). Compositions are denoted by a filled-diamond adornment on the association. Window Scrollbar Titlebar Menu 1 1 1 1 1 1 .. *
  • 36. © SERG Software Design (UML) Software Design Dynamic Modeling using the Unified Modeling Language (UML)
  • 37. © SERG Software Design (UML) State Machine An object must be in some specific state at any given time during its lifecycle. An object transitions from one state to another as the result of some event that affects it. You may create a state diagram for any class, collaboration, operation, or use case in a UML model . There can be only one start state in a state diagram, but there may be many intermediate and final states.
  • 38. © SERG Software Design (UML) State Machine start state final state simple state concurrent composite state sequential composite state
  • 39. © SERG Software Design (UML) State Machine selecting verifying downloading checking schedule download course offerings make a course selection verify selection check schedule select another course make a different selection unscheduled scheduled sign schedule
  • 40. © SERG Software Design (UML) Collaboration Diagram A collaboration diagram emphasizes the relationship of the objects that participate in an interaction. Unlike a sequence diagram, you don’t have to show the lifeline of an object explicitly in a collaboration diagram. The sequence of events are indicated by sequence numbers preceding messages. Object identifiers are of the form objectName : className, and either the objectName or the className can be omitted, and the placement of the colon indicates either an objectName: , or a :className.
  • 41. © SERG Software Design (UML) Collaboration Diagram : Order Entry Window : Order : Order Line :Delivery Item : Stock Item :Reorder Item 1: prepare() 2*: prepare() 3: check() 4: [check == true] remove() 6: new 7: [check == true] new 5: needToReorder() [Fowler,97] Self-Delegation Object Message Sequence Number
  • 42. © SERG Software Design (UML) Activity Diagram An activity diagram is essentially a flowchart, showing the flow of control from activity to activity. Use activity diagrams to specify, construct, and document the dynamics of a society of objects, or to model the flow of control of an operation. Whereas interaction diagrams emphasize the flow of control from object to object, activity diagrams emphasize the flow of control from activity to activity. An activity is an ongoing non-atomic execution within a state machine. - The UML User Guide, [Booch,99]
  • 43. © SERG Software Design (UML) [Fowler,97] Receive Order Authorize Payment Check Line Item Cancel Order Assign to Order Reorder Item Dispatch Order [failed] [succeeded] [in stock] * for each line item on order [need to reorder] [stock assigned to all line items and payment authorized] Synchronization Condition Multiple Trigger
  • 44. © SERG Software Design (UML) References [Booch99] Booch, Grady, James Rumbaugh, Ivar Jacobson, The Unified Modeling Language User Guide, Addison Wesley, 1999 [Rambaugh99] Rumbaugh, James, Ivar Jacobson, Grady Booch, The Unified Modeling Language Reference Manual, Addison Wesley, 1999 [Jacobson99] Jacobson, Ivar, Grady Booch, James Rumbaugh, The Unified Software Development Process, Addison Wesley, 1999 [Fowler, 1997] Fowler, Martin, Kendall Scott, UML Distilled (Applying the Standard Object Modeling Language), Addison Wesley, 1997. [Brown99] First draft of these slides were created by James Brown.