Example Collaboration Diagrams1.1: *getAccountDetails:withdrawUI :withdrawCtrl Campaign Manager Allocation of responsibilities for use case withdraw 4.1.1: withdraw... Sequence Diagrams
Trang 1Chương 3 THU THẬP YÊU CẦU
HƯỚNG ĐỐI TƯỢNG (cont)
Trang 2Cơ 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()
Trang 3Interaction (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.
Trang 4Example Collaboration Diagrams
1.1: *getAccountDetails():withdrawUI :withdrawCtrl
Campaign
Manager
Allocation of responsibilities for use case withdraw
4.1.1: withdraw()
Trang 5Sequence Diagrams
Show an interaction between objects arranged in a time sequence
Can be drawn at different levels of detail and to meet different
purposes at several stages in the development life cycle
Typically used to represent the detailed object interaction that occurs for one use case or for one operation
Trang 6Sequence Diagrams
the page and represented by lifelines
Trang 7Sequence diagram with entity objects only
:Card :Account
listAccounts()
withdraw()
*getAccountDetails( )
Object lifeline
Activation
Client
Trang 8Sequence diagram with entity objects only
:Client :Campaign :Advert
getName()listCampaigns()
listAdverts()
*getCampaignDetails()
Advert()
*getAdvertDetails()
Trang 9Boundary & Control Classes
*getAccountDetails():withdrawUI
:withdrawCtrl :Card :Account
withdraw()selectAccount()
withdraw()startInterface() listClient()
Client
Use Case: withdraw
Trang 10Boundary & Control Classes
Trang 11Object Destruction (hủy)
Trang 12getOverheads()Campaign
Manager
Trang 13 May be shown by shading those parts of the activation rectangle that correspond to active processing by an operation
Trang 15-< 6 sec}
Synchronous (blocking) message
Asynchronous message
Callback
Time
constraints
Construction marks to show time constrained interval
{e’ – e < 6 sec}
An active
object
Here e is used as shorthand for
e.sendtime and
e’ represents e.receivetime
Trang 16Campaign
Manager
Trang 17Handling Complexity
diagrams suitably annotated
single lifeline, and interaction among these objects is shown
on a different diagram
Trang 18Handling Complexity
:AddAdvertUI
:AddAdvert
showClientCampaigns()selectClient()
These flows are continued next figurestartInterface()
*getClient()
Campaign
Manager
Trang 20Object Grouping
Lifeline representing a set of objects
Trang 21Collaboration 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
Trang 22Collaboration Diagrams
1.1: *getAccountDetails():withdrawUI :withdrawCtrl
Campaign
Manager
Allocation of responsibilities for use case withdraw
4.1.1: withdraw()
Trang 23:Client :Campaign :Advert
3.1: showClientCampaigns()3: selectClient()
Campaign
Manager
One allocation of responsibilities for use case
Add a new advert to a campaign
Trang 24: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
Trang 25Message
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.
concurrent messages 3.1a and
3.1b are completed.
3.1a, 3 1b / 4:playVideo()
Trang 26Activity Diagrams
other uses
technique
Trang 27Link to CreativeStaff
Create new
StaffGrade
Link to previous StaffGrade
Set previous StaffGrade gradeFinishDate
Simple Activity Diagram
Trang 28Check approval for grade change
Create new StaffGrade
Link to previous StaffGrade
Set previous StaffGrade gradeFinishDate
Activity Diagram with Selection
Trang 29Add to ‘star’ list
Create warning letter
[bonus < £25]
[bonus >= £25 AND bonus <= £250]
Activity Diagram with Selection and
Iteration
Trang 30Get Account Details
[NoOfAccounts = 1]
[amount < =A balance]
A.balance A.balance-amount Result TRUE
List an Account details
A Only Account
Activity Diagram- Withdraw
Trang 31Object Constraint Language
Most OCL statements consist of:
Context, Property and Operation
Context
Defines domain within which expression is valid
Instance of a type, e.g object in class diagram
Link (association instance) may be a context
A property of that instance
Often an attribute, association-end or query operation
Trang 32 Arithmetical operators *, +, - and /
Set operators such as size, isEmpty and select
Type operators such as oclIsTypeOf
Trang 33OCL expression Interpretation
Person
self.gender
In the context of a specific person, the value of the property ‘gender’ of that person—i.e a person’s gender.
Person
self.savings >= 500
The property ‘savings’ of the person under consideration must be greater than or equal to 500.
Company
self.CEO->size <= 1
The size of the set of the property ‘CEO’
of a company must be less than or equal to 1 That is, a company cannot have more than 1 Chief Executive Officer.
Company
self.employee->select (age < 60)
The set of employees of a company whose age is less than 60.