Upload
scodrash
View
219
Download
0
Embed Size (px)
Citation preview
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
1/69
Chapter 3Modeling with UnifiedModeling Language
A Deeper View of UML
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
2/69
UML Diagrams:Outline of this ClassUse case diagrams
Describe the functional behavior of the system as seen by theuser Interaction diagrams
Describe the dynamic behavior between objects of the system
Activity diagramsDescribe the dynamic behavior of a system, in particular theworkflow.
Class diagrams
Describe the static structure of the system: Objects, attributes,associations
Statechart /State Machine diagramsDescribe the dynamic behavior of an individual object
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
3/69
Activity Diagram
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
4/69
describe the workflow behavior of a system.describe the state of activities by showing thesequence of activities performed. show activities that are conditional orparallel.focuses on flows driven by internalprocessing
4
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
5/69
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
6/69
Notation of ActivityDiagrams
Actionsrectangle with rounded corners
Add a NewClient
mean ng u nameControl flows
arrows with open
arrowheads
Assign Staff Contact
6
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
7/69
Notation of ActivityDiagramsInitial node
black circleDecision nodesand mer e nodes
Add a New
Client
Assign Staff Contact
diamond
Guard conditionsin square brackets
Final nodeblack circle in white circle
[no campaign to add]
[campaign to add]
Add NewCampaign
7
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
8/69
Notation of ActivityDiagrams
Fork nodesand join nodes
thick bar
Add a New
Client
Actions carriedout in parallel
ss gn aContact
Campaign
8
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
9/69
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
10/69
Notation of ActivityDiagrams
Activity Partitions(Swimlanes)
Record Completionof a campaign
CampaignManager
Client Accountant
labelled with theperson, organisation,department or
system responsiblefor the activities inthat column
Issue invoice
Pay invoice
Record clientpayment
10
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
11/69
The main reason to use activity diagrams isto model the workflow behind the systembeing designed.
Activity Diagrams are also useful for:analyzing a use case by describing what actions needto take place and when they should occur;
describing a complicated sequential algorithm;modeling applications with parallel processes .
11
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
12/69
Enter card Read card
Request PINEnter PIN
Example of Activity Diagram for ATM Authorization
Verify PIN valid?
Select otherservice
[Yes]
12
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
13/69
Swimlane- partition anactivity diagram sothat parts in theswimlane relevantto that activities inthe partition-
13
investigatingresponsibilities forinteractions andassociationsbetween objectsand actors
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
14/69
Activity diagram with
synchronization bars split into multiple
paths and multiple paths combined into
a single transition
Top synchronizationbar is a fork.
14
Bottomsynchronization baris a join.
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
15/69
15
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
16/69
Model interactions between objects/classes Assist in understanding how a use caseactually works
Verify that a use case description can besupported by the existing classesIdentify methods/operations and assign themto classes
16
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
17/69
State Diagrams
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
18/69
Statechart Diagramsused to describe the dynamic behavior of anindividual object as a number of states andtransitions between these states.describe all of the possible states of an object
as events occur.each diagram usually represents objects of asingle class and track the different states of itsobjects through the system
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
19/69
Initial state
Transition
Event
button1&2Pressed
button1Pressed
button2Pressed
button2Pressed button1&2Pressed Increment Minutes
Increment Hours
Blink Hours
Blink Minutes
State
Final state
Represents behavior of a single object withinteresting dynamic behavior.
button2Pressed
button1Pressed
Blink Seconds
Increment Seconds
Stop Blinking
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
20/69
When to use StateDiagram?
Use state diagrams to demonstrate thebehavior of an object through many usecases of the system.
Only use state diagrams for classes where itis necessary to understand the behavior ofthe object through the entire system
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
21/69
M lin r r
21
Class Diagram
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
22/69
Classes are composed of three things: aname, attributes, and operations
22
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
23/69
Show the static structure of the model
A collection of static modeling elements, such asclasses and their relationships, connected to each other
represented by the actual objects in the program
The visual representation of the objects, theirrelationships, and their structure for ease ofunderstanding
What you need? determine the objects required in thesystem
23
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
24/69
Class Diagram: Associations
Associations represent:The possibility of a logical relationship orconnection between objects of one class
Grace Chia is the staff contact for FoodCo An employee object is linked to a client object
If two objects are linked, their classes aresaid to have an association
24
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
25/69
Class Diagram: Links
Yellow Partridge:Client
A link is a logical connectionbetween two objects
FoodCo:Client
Soong Motor Co:Client
Grace Chia:StaffMember
Carlos Moncada:StaffMember
25
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
26/69
Class Diagram: Associations
StaffMember Client
companyAddress
Association role Association
staffName
staffNostaffStartDate
companyEmailcompanyFaxcompanyNamecompanyTelephone
liaises with
Association name Direction in whichname should be read
26
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
27/69
Class Diagram: Multiplicity
Associations have multiplicity: the range ofpermitted cardinalities of an associationRepresent enterprise (or business ) rules
ese a ways come n pa rs: Associations must be read separately fromboth ends
Each bank customer may have 1 or moreaccountsEvery account is for 1, and only 1, customer
27
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
28/69
Class Diagram: Multiplicity
StaffMember Client
companyAddress*
Multiplicities
staffNostaffStartDate
companyFaxcompanyName
companyTelephone
..
liaises with
Exactly one staff member liaises with each client
A staff member may liaise with zero, one or more clients
28
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
29/69
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
30/69
Motor Vehicle
30
Bus Truck Car
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
31/69
A relationship between classes where oneclass is parent class(superclass) of anotherclass
Allows objects to be built from other objects Allows classes to share and reuse behaviorsand attributes
31
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
32/69
class Person {String Name;
}
32
class Employee extends Person{}
classClient
extendsPerson {}
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
33/69
Objects are composed of and may containother objectsE.g, car object is an aggregation of other
, ,objects.
33
Car
Engine Seat Wheel
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
34/69
has
34
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
35/69
Class diagrams are used in nearly all ObjectOriented software designs.Use them to describe the Classes of the
system and their relationships to each other Show relationship of all classes and objectas an overall picture
35
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
36/69
User
AddressMember#
Library Item
No. CopiesShelfNoStatusTitleIssueReturn
Borrows
Aggregation
Association GeneralizationObject /Class
0..*
Name
SubscribeUnsubscribe
External Reader
Ext. Library NameBorrower
Items BorrowedMaximum Loans Book
Author ISBNPub. DatePublisher
CAL PackageDistributor
Recorded Media
Course Text
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
37/69
PlanAnalyst
PlanMetrics
Plan
GrowingPlan GardeningPlan
FruitGrowin Plan
analyzes
1..2
1..*
OOAD
37
Controller Cooler
Light Heater
Food
Vitamin Calorie
1..231 1
*
* 1
**
* 1
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
38/69
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
39/69
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
40/69
prepare() prepare()
check()
:ReorderItem
:DeliveryItem
:Order Entrywindow
:Order :Order Line :Stock Item
40
tru remove()
needsToReorder()
[needsToReorder=true]
enter new
[check=true]enter new
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
41/69
ReOrderItem
itemnumber quantityetc
DeliveryItem
Order
orderNumber dateetc
prepare()
OrderLine
itemnumber quantityetc
StockItem
orderNumber is for
prepare()enter new()
41
quantityetcdateetc
needsToReorder(): boolean
check(): booleanremove()
_
enter new()
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
42/69
Class Diagram 42
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
43/69
The requirements list of a company includes thefollowing description of the use case make anorder
43
We have customers who make an order We distinguish corporate customers from personal customers, since corporate
customers are billed monthly whereas personal customers need to prepay their orderswith a credit cardWe want our orders to be lined up product by productEach line should contain the amount and the price of each product
make an orderCustomer
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
44/69
Order Customer
* make 1
44
We have customers who make an order We distinguish corporate customers from personal customers, since corporatecustomers are billed monthly whereas personal customers need to prepay their orders
with a credit cardWe want our orders to be lined up product by product. Each line should contain theamount and the price of each product
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
45/69
Order Customer
* make 1
45
We have customers who make an order
We distinguish corporate customers from personal customers, since corporatecustomers are billed monthly whereas personal customers need to prepay theirorders with a credit cardWe want our orders to be lined up product by product. Each line should contain the
amount and the price of each product
Corporate Personal
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
46/69
Order Customer
* make 1
1
46
We have customers who make an order
We distinguish corporate customers from personal customers, since corporatecustomers are billed monthly whereas personal customers need to prepay their orderswith a credit cardWe want our orders to be lined up product by product. Each line should contain
the amount and the price of each product
Corporate PersonalOrderLine Product
*
* 1
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
47/69
Order
orderID:char
Price:money
Customer
name:charaddress:char* make 1
*
1
47
We have customers who make an order
We distinguish corporate customers from personal customers, since corporatecustomers are billed monthly whereas personal customers need to prepay their orderswith a credit cardWe want our orders to be lined up product by product. Each line should contain the
amount and the price of each product
Corporate
billMonthly(int)
Personal
CreditcardNo:char
OrderLine
Amount:IntegerPrice:money
Product
* 1
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
48/69
Summary: UML Diagrams
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
49/69
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
50/69
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
51/69
Model the physical components (e.g., source
code, program, user interface) in a design Addresses the static implementation view ofa s stem
Built as part of architectural specificationPurpose
Organize source code
Construct an executable releaseSpecify a physical database
Developed by architects and programmers51
f
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
52/69
Notation ofComponent Diagrams
Componentsrectangles with a component icon in the topright-hand corner ma rovide or re uire interfaces
Dependencies between components
52
Productionscheduler
Staff planner
Productionscheduler
Staff planner
N i f
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
53/69
Notation ofComponent Diagrams
Wiring connection ( ball-and-socketconnectors ) between required and provided interfaces
e uired inter ace Provided inter ace
Productionscheduler
Staff planner
PlanningScheduling
Productionscheduler
Staff planner
PlanningScheduling
53
Production scheduler requires the Planning servicefrom Staff planner . Staff planner provides thePlanning service
N i f
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
54/69
Notation ofComponent Diagrams
Component with portsIndicates that the component delegatesresponsibility for the behaviour of thatinterface to a subcomponent
Spooler
PrinterDriver Spooling
Spooler
PrinterDriver Spooling
54
port
N i f
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
55/69
Notation ofComponent Diagrams
Component with portsShows delegated responsibility
Spooler
:PrintManager
:File
PrinterDriver Spooling
PrintSpooling
Printing
delegate delegate
Spooler
:PrintManager
:File
PrinterDriver Spooling
PrintSpooling
Printing
delegate delegate
55
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
56/69
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
57/69
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
58/69
Captures the topology of a systems hardware
Show the configuration of run-time processingelements and the s/w components, processes,and objects that live in them
Built as part of architectural specificationPurpose
Specify the distribution of components
Identify performance bottlenecksDeveloped by architects, networking engineers,and system engineers
58
Notation of
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
59/69
Notation of Deployment Diagrams
Nodesrectangular prismsrepresent processors, devices or other
Communication Associationslines between nodesrepresent communication between nodescan be stereotyped
59
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
60/69
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
61/69
Notation of
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
62/69
Notation of Deployment Diagrams
PC Client Server PC Client Server
RMI AgateServer.jar AgateClient.jar RMI AgateServer.jar AgateClient.jar
62
Notation of
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
63/69
Notation of Deployment Diagrams
Nodes can be stereotyped A device is a kind ofcomposite node that consistsof other devices or nodes
device:AppServer
executionenv
device:AppServer
executionenv
Execution environmentsrepresent applicationcontainers
Deployment specificationsdescribe the configuration ofartefacts
AgateServer.war
deploymentspecserverconfig.xml
AgateServer.war
deploymentspecserverconfig.xml
63
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
64/69
64
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
65/69
Another way of looking at components A package is a grouping of model elements(e.g., group of classes)
ac ages t emse ves may conta n ot erpackages
A package may contain both subordinatepackage and ordinary model elements
All UML model elements and diagrams canbe organized into packages
65
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
66/69
dependency
66
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
67/69
Summary A deeper view of UML
Use case diagramSequence Diagram
Statechart DiagramClass DiagramPhysical Diagrams
67
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
68/69
Architecture and the UML
Design View ImplementationView
Process View Deployment View
Use CaseView
logical physical
8/10/2019 OO Concept Chapt3 Part3%28deeperViewOfUML%29
69/69
Additional ReadingsThe Elements of UML 2.0 Style, Scott W.
Ambler, Ronin International, 2005The Object Primer 3rd Edition, Scott W.
Ambler, Cambridge University Press, 2004UML Distilled: A Brief Guide to the StandardObject Modeling Language (3rd Edition),
Martin Fowler, Addison-WesleyProfessional, 2004