《软件工程》Computer Science 中_OK

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

these two * symbols used together imply
iteration over the multiobject and sending the for example,Laistobject containing many
getSubtotaml essage to each member
Object-Oriented Design
Collaboration / Design DiagramBillsBond
11/06/02
Chapter 14 - Design
• Dynamic view, Interaction Diagrams - How objects will communicate to fulfill requirements • Assign responsibilities • Design patterns
create message, with optional initializing parameters. This will normally be interpreted as a constructor call.
: Register : Register
1: create(cashier)
1a and 1b are mutually exclusive conditional paths
1a [test1] : msg2()
:ClassB
1b [not test1] : msg4()
1a.1: msg3()
:ClassD
1b.1: msg5()
:ClassC
23
Iteration
runSimulation() : Simulator 1 * [i:=1..N]: num := nextInt() : Random
24
Iteration over Collection
t := getTotal()
: Sale
1 *: st := getSubtotal()
*
:SalesLineItem :SalesLineItem
double box indicates a multiobject (collection)
spec := getProductSpec( id )
spec := getProductSpec( id : ItemID )
spec := getProductSpec( id : ItemID ) : ProductSpecification
15
Links
: Register
1: makePayment(cashTendered) 2: foo()
11
Approach
• Create separate diagram for each system operation • System operation is starting message
• If diagram gets complex (greater than 8.5x11) split into smaller diagrams
8
Example - Collaboration
direction of message
first internal message
makePayment(cashTendered) : Register
1: makePayment(cashTendered) :Sale
first message parameter
Message Number Sequencin g
msg1()
:ClassA
1: msg2()
:ClassB
not numbered
legal numbering
1.1: msg3() :ClassC
20
Message Number Sequencin g
first
msg1()
;ClassA
second 1: msg2()
SalesLineItemobjects
Collection - multiobject
25
Message to a Class
msg1() : InstanceOfFoo
message to class, or a static method call
list := synchronizedList( aList ) java.util.Collections
Diagram Types
4
Collaboration Diagram
message1()
:ClassAInstance
1: message2() 2: message3()
:ClassBInstance
5
Sequence Diagram
:ClassAInstance
:ClassBInstance
27
Message to “self” or “this”
: Register
msg1()
clear()
28
Creation of Instance
: Register
: Sale
note that newly created objects are placed at their creation "height"
13
Class And Instances
Sale class
:Sale instance
s1: Sale named instance
Instance is underlined Class name preceded by colon
14
Message Syntax
Return := message(parameter : parameterType) : returnType Parts are optional
not underlined, therefore a class
Static method
26
Sequence Diagram - Messag es
: Register msg1()
msg2() msg3() msg4()
msg5()
: Sale
Focus of Control - Activation Box
10
Important Artifact
• Assign responsibilities • Design object collaborations • Significant amount of time • Use patterns - structural guidelines and principles • Notation-only chapter
:ClassB
third
2: msg4()
1.1: msg3() 2.1: msg5() :ClassC
fourth
fifth 2.2: msg6()
sixth
:ClassD
21
Conditional Message
conditional message, with test
message1()
: Foo
• Domain model • System operation contracts • Use cases • Starting point - fulfillment of operation contract post-conditions
3
• Two types • Collaboration • Sequence
mak ePay ment( c as hT endered) create(cashTendered) : Payment
author iz e()
an object lifeline shows the extent of the life of the object in the diagram
12
Approach
• Use operation contract responsibilities / post-conditions and use case description as starting point • Design system of interacting objects to fulfill tasks • Apply GRASP and patterns to develop good design
anactivation bosxhowing the focus of control
makePayment(cashTendered) create(cashTendered) : Payment
Same as previous diagram
Emphasizes “focus of control”
message1()
message2()
message3()
6
Sequence Diagram
• Strengths • Clearly shows sequence or time ordering
• Weaknesses • Must add new vertical line when adding new objects
• Static view, Design Class Diagrams - Definition of class and interfaces
2
Chapter 15 - Interaction Diagrams
• Illustrates how objects interact via messages to fulfill tasks • Prior artifacts
1 [ color = red ] : calculate()
: Baate to TRUE
22
Mutually Exclusive
unconditional after either msg2 or msg4
:ClassE
2: msg6() msg1() :ClassA
7
Collaboration Diagram
• Strengths • Space economical • Easier to illustrate complex branching, iteration, and concurrent behavior
• Weaknesses • Difficult to see sequence of messages • More complex notation
iteration is indicated with a * and an optional iteration clause following the sequence number
Iteration indicated by * Sent repeatedly specified number of times
3.1: msg5()
all messages flow on the same link
Labeled arrow Sequence
:Sale 17
Message to “self” or “this”
msg1() : Register
1: clear()
18
Creation of Instance
2.1: bar()
:Sale
link line
Connection path between instances
Instance of an association
Client to server message
16
Messages
msg1() : Register
1: msg2() 2: msg3() 3: msg4()
link line
1.1: create(cashTendered)
instance
creation indicated with a "create" message
:Payment
9
Example - Sequence
: Register
: Sale
makePayment(cashTendered)
玞reate? 1: make(cashier)
:Sale {new} :Sale {new}
if an unobvious creation message name is used, the message may be stereotyped for clarity
Create is language independent Create maps to C++ “new”+constructor 19
相关文档
最新文档