Chương 3 THU THẬP YÊU CẦU
HƯỚNG ĐỐI TƯỢNG (cont)
Lược đồ cộng tác
Lược đồ trình tự
Lược đồ hoạt động
Cơ chế truyền thông điệp của đối tượng
UML :Book sam:Student
getFineDue( )
Các đối tượng trao đổi thông tin thông qua cơ chế
truyền thông điệp.
Gửi thông điệp getFineDue() đến đối tượng
Student thực hiện cú pháp sau:
fine = sam.getFineDue()
Interaction (sự tương tác) & Collaboration
The structure of Instances playing roles in a behaviour and their relationships is
called a Collaboration.
An Interaction is defined in the context of a Collaboration. It specifies the
communication patterns between the roles in the Collaboration.
More precisely, it contains a set of partially ordered Messages, each specifying one
communication,
e.g. what Signal to be sent or what Operation to be invoked, as well as the roles
played by the sender and the receiver, respectively.
Example Collaboration Diagrams
1.1: *getAccountDetails()
:withdrawUI
:withdrawCtrl
:Card :Account
3: selectAccount()
4: getAmount()
4.1: withdraw()
2: startInterface()
listAdverts()
*getCampaign
Details()
Advert()
*getAdvert
Details()
newAd:Advert
addNewAdvert()
Object lifeline
Activation
Object creation
Campaign
Manager
Boundary & Control Classes
*getAccountDetails()
:withdrawUI
:withdrawCtrl
:Card
:Account
withdraw()
selectAccount()
withdraw()
startInterface()
listClient()
Client
Use Case: withdraw
Boundary & Control Classes
listCampaigns()
*getCampaignDetails()
Advert()
getName()
listCampaigns()
checkCampaignBudget()
*getCampaign
Details()
*getCost()
getOverheads()
Campaign
Manager
Focus of Control
Indicates times during an activation when processing is taking place
within that object
Parts of an activation that are not within the focus of control represent
periods when, for example, an operation is waiting for a return from
another object
May be shown by shading those parts of the activation rectangle that
correspond to active processing by an operation
Focus of Control
:Client :Campaign :Advert
getName()
listCampaigns()
checkCampaignBudget()
*getCampaignDetails()
* getCost()
getOverheads()
Campaign
Manager
Further Notation
:ClassA
:ClassB
shorthand for
e.sendtime and
e’ represents
e.receivetime
Message Branching
[totalCost budget] Advert()
addCostedAdvert()
[totalCost > budget] Request()
newAd:Advert
newRequest:Request
:Campaign
budget:=checkCampaignBudget()
checkCampaignBudget()
results in further interaction
Campaign
Manager
Handling Complexity
Complex diagrams can be split into two or more smaller
diagrams suitably annotated
Alternatively a group of objects can be represented by a
single lifeline, and interaction among these objects is shown
on a different diagram
Handling Complexity
:AddAdvertUI
:AddAdvert
showClientCampaigns()
selectClient()
selectCampaign()
showCampaignAdverts()
createNewAdvert()
set of objects
getName()
CampaignAdverts
checkCampaignBudget()
:Client
listCampaigns()
Campaign
Manager
Collaboration Diagrams
Sơ đồ Cộng tác
Hold the same information as sequence diagrams
Show links between objects that participate in the collaboration
No time dimension, sequence is captured with sequence numbers
Sequence numbers are written in a nested style (for example, 3.1 and
3.1.1) to indicate the nesting of control within the interaction that is
being modelled
Collaboration Diagrams
1.1: *getAccountDetails()
:withdrawUI
:withdrawCtrl
:Card :Account
3: selectAccount()
4: getAmount()
4.1: withdraw()
2: startInterface()
1:listCampaigns()
Campaign
Manager
Allocation of responsibilities for use case withdraw
4.1.1: withdraw()
:Client :Campaign
:Advert
3.1: showClientCampaigns()
3: selectClient()
4: selectCampaign()
4.1: showCampaignAdverts()
4.1.1: listAdverts()
5: createNewAdvert()
5.1: addNewAdvert()
newAd:Advert
2: startInterface()
3.1.1: listCampaigns()
1:*getClient()
Campaign
Manager
Alternative allocation of responsibilities for use case
Add a new advert to a campaign
Message
Labels
Type of message Syntax example
Simple message.
4: addNewAdvert()
Nested call with return value.
The return value is placed in the
variable name.
3.1.2: name:= getName()
Conditional message.
This message is only sent if the
condition [balance > 0] is
true.