com s 362: object-oriented analysis and design interaction diagrams and responsibility assignment...
DESCRIPTION
Com S 362: Object-Oriented Analysis and Design 3 3 Recap: Class Diagrams Class diagrams represent design structure Three parts: name, attribute, operations Visibility, attribute type, multiplicity Association, association multiplicity Generalization i.e. interface impl, subclassing Composition i.e. class A contains class B Applied information hiding, DSM, layeringTRANSCRIPT
![Page 1: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/1.jpg)
Com S 362: Object-Oriented Analysis and Design
Interaction Diagrams and
Responsibility Assignment Oct 23, 2006
![Page 2: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/2.jpg)
2 Com S 362: Object-Oriented Analysis and Design2
Com S 362: Object-Oriented Analysis and Design
Recap: CRC Cards Process1. Initial class list2. Refined class list3. while (More use case scenarios left)4. do5. Take a use case scenario6. Assign responsibilities to classes7. Find super- and sub-classes8. Find collaborators9. od
![Page 3: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/3.jpg)
3 Com S 362: Object-Oriented Analysis and Design3
Com S 362: Object-Oriented Analysis and Design
Recap: Class Diagrams Class diagrams represent design structure Three parts: name, attribute, operations Visibility, attribute type, multiplicity Association, association multiplicity Generalization i.e. interface impl, subclassing Composition i.e. class A contains class B Applied information hiding, DSM, layering
![Page 4: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/4.jpg)
4 Com S 362: Object-Oriented Analysis and Design4
Com S 362: Object-Oriented Analysis and Design
Today’s Lecture Interaction Diagrams Basics & Notations Responsibility Assignment Principles
![Page 5: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/5.jpg)
5 Com S 362: Object-Oriented Analysis and Design5
Com S 362: Object-Oriented Analysis and Design
Example: Switch-Motor System Scenario: Motor can run, when the Switch
state is on Class list: Switch and Motor R1: Store the decision condition R2: Make a decision R3: Run the motor
![Page 6: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/6.jpg)
6 Com S 362: Object-Oriented Analysis and Design6
Com S 362: Object-Oriented Analysis and Design
Class Diagram View
Switch
-state:bool
+getState():bool
Motor
-switch:Switch
+run()
1
switch
![Page 7: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/7.jpg)
7 Com S 362: Object-Oriented Analysis and Design7
Com S 362: Object-Oriented Analysis and Design
Interaction Diagram View:Motor switch:Switch
rungetState
Lifeline boxes
state
![Page 8: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/8.jpg)
8 Com S 362: Object-Oriented Analysis and Design8
Com S 362: Object-Oriented Analysis and Design
Switch-Motor: CRC Card View Scenario: Motor can run, when the Switch state is on Class list: Switch and Motor R1: Store the decision condition, R2: Make a decision, and
R3: Run the motor
Class Name: SwitchSubclasses: Super classes:
Responsibilities CollaboratorsStore decision condition
Class Name: MotorSubclasses:Super classes:
Responsibilities CollaboratorsMake a decision Switch
Run the motor
![Page 9: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/9.jpg)
9 Com S 362: Object-Oriented Analysis and Design9
Com S 362: Object-Oriented Analysis and Design
Class Diagram View
Switch
-state:bool
+getState():bool
Motor
-switch:Switch
+run():void
1
switch
void run(){if(switch.getState()){ /* Make a decision */ /* run the motor */ } }
![Page 10: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/10.jpg)
10 Com S 362: Object-Oriented Analysis and Design10
Com S 362: Object-Oriented Analysis and Design
Impact of Change: Multi-State Switch
Switch
-state:bool
+getState():bool
Motor
-switch:Switch
+run():void
1
switch
void run(){if(switch.getState()){ /* Make a decision */ /* run the motor */ } }
-state:int
+getState():int
Change: Switch can have more than two states.
![Page 11: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/11.jpg)
11 Com S 362: Object-Oriented Analysis and Design11
Com S 362: Object-Oriented Analysis and Design
Change Escapes Module Boundary
Switch
-state:bool
+getState():bool
Motor
-switch:Switch
+run():void
1
switch
void run(){if(switch.getState()){ /* Make a decision */ /* run the motor */ } }
Change: Switch can have more than two states.
-state:int
+getState():int
Impact of Change
![Page 12: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/12.jpg)
12 Com S 362: Object-Oriented Analysis and Design12
Com S 362: Object-Oriented Analysis and Design
Information Expert Which class has the necessary information? Example – class list: Switch and Motor R1: Store the decision condition, R2: Make a
decision, and R3: Run the motorClass Name: SwitchSubclasses: Super classes:
Responsibilities CollaboratorsStore decision Condition
Make a decision
Class Name: MotorSubclasses:Super classes:
Responsibilities CollaboratorsRun the motor Switch
![Page 13: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/13.jpg)
13 Com S 362: Object-Oriented Analysis and Design13
Com S 362: Object-Oriented Analysis and Design
Improved Class Diagram View
Switch
-state:bool
+isOn():bool
Motor
-switch:Switch
+run():void
1
switch
void run(){if(switch.isOn()){ /* run the motor */ } }
![Page 14: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/14.jpg)
14 Com S 362: Object-Oriented Analysis and Design14
Com S 362: Object-Oriented Analysis and Design
Implementation Changes Encapsulated
Switch
-state:bool
+isOn():bool
Motor
-switch:Switch
+run():void
1
switch
void run(){if(switch.isOn()){ /* run the motor */ } }
Change: Switch can have more than two states.
-state:int
+isOn():bool
Remember: Information Hiding
![Page 15: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/15.jpg)
15 Com S 362: Object-Oriented Analysis and Design15
Com S 362: Object-Oriented Analysis and Design
Example: User-Level Process Management Main scenario: A process will maintain necessary
information for it to run such as program counter (PC), reference to program segment (.ps), reference to data segments (.ds), registers (regs)
Scenario of interest: functionality to create an identical copy of a process should be provided
Class list: process, client R1: store information PC, .ps, .ds. Regs R2: create copy of process
![Page 16: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/16.jpg)
16 Com S 362: Object-Oriented Analysis and Design16
Com S 362: Object-Oriented Analysis and Design
User-Level Process Management : CRC Card View Class list: process, client R1: store information pc, .ps, .ds. regs R2: create copy of process
Class Name: ProcessSubclasses: Super classes:
Responsibilities CollaboratorsStore information pc, .ps, .ds. regs
Class Name: Client …Subclasses:Super classes:
Responsibilities CollaboratorsCreate copy Processof .pc, .ps, .ds, .regs Spawn anotherprocess
![Page 17: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/17.jpg)
17 Com S 362: Object-Oriented Analysis and Design17
Com S 362: Object-Oriented Analysis and Design
Change: Register-based to Stack-based Machine Class list: process, client R1: store information pc, .stack, .top, .ps, .ds. R2: create copy of process
Class Name: ProcessSubclasses: Super classes:
Responsibilities CollaboratorsStore information pc, .stack, .top, .ds. regs
Class Name: Client …Subclasses:Super classes:
Responsibilities CollaboratorsCreate copy Processof .pc, .ps, .ds, .regs Spawn anotherprocess
Impact on all clients
![Page 18: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/18.jpg)
18 Com S 362: Object-Oriented Analysis and Design18
Com S 362: Object-Oriented Analysis and Design
Creator: Which class has the initializing data? Class list: process, client R1: store information pc, .ps, .ds. regs R2: create copy of process
Class Name: ProcessSubclasses: Super classes:
Responsibilities CollaboratorsStore information pc, .ps, .ds. regs
Create copy of .pc, .ps, .ds, .regs and spawn another process
Class Name: Client …Subclasses:Super classes:
Responsibilities Collaborators Process Chang
e Impact Encap-sulate
d
![Page 19: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/19.jpg)
19 Com S 362: Object-Oriented Analysis and Design19
Com S 362: Object-Oriented Analysis and Design
Adding GUI to the Sorting Application
Integers (>0)
Sorting Algorithm
Sorting Application
Merge Sort
Sort: User
• Which class should handle the Sort Event?Class Name: UISubclasses: Super classes:
Responsibilities CollaboratorsHandle Sort SortingAppEvent
Class Name: SortingAppSubclasses:Super classes:
Responsibilities CollaboratorsCreate sorting, ISort, IStoragestorage instance etc.
![Page 20: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/20.jpg)
20 Com S 362: Object-Oriented Analysis and Design20
Com S 362: Object-Oriented Analysis and Design
Adding GUI to the Sorting Application
SortButton
…
/addActionListener(ActionListener l)
javax.swing.DefaultButtonModel
…
+addActionListener(ActionListener l)
SortingApplicationstorage:IStorage
sort:ISort
+sort(…):IStorage/actionPerformed(ActionEvent e)
java.awt.event.ActionListener
…
+actionPerformed(ActionEvent e)
![Page 21: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/21.jpg)
21 Com S 362: Object-Oriented Analysis and Design21
Com S 362: Object-Oriented Analysis and Design
Summary Interaction Diagrams Responsibility Assignment Principles
Information Expert Creator Controller Polymorphism Pure Fabrication Indirection Protected Variations
![Page 22: Com S 362: Object-Oriented Analysis and Design Interaction Diagrams and Responsibility Assignment Oct 23, 2006](https://reader036.vdocuments.mx/reader036/viewer/2022062412/5a4d1b137f8b9ab0599906d4/html5/thumbnails/22.jpg)
22 Com S 362: Object-Oriented Analysis and Design22
Com S 362: Object-Oriented Analysis and Design