Date post: | 24-Dec-2015 |
Category: |
Documents |
Upload: | silas-warren |
View: | 220 times |
Download: | 1 times |
O
bje
ct-O
rien
ted
Des
ign
1
**Object-Oriented DesignObject-Oriented Design (Schach Chap 14) (Schach Chap 14)
Goal:Goal: Design product Design product in terms of objects in terms of objects identified during OOAidentified during OOA
OOD consists of four steps:OOD consists of four steps:1. Construct interaction diagrams
for each scenario. Two types:a. Collaboration Diagrams (Spatial), b. Sequence Diagrams (Temporal)
2. Develop detailed class diagram3. Design the product in terms of
clients of objects4. Proceed to detailed design
1..3 Constitute “High-Level” Design
Result of our Elevator System Result of our Elevator System OOA: A UMLOOA: A UML Class Diagram Class Diagram
O
bje
ct-O
rien
ted
Des
ign
2
*Step 1 of OOD: *Step 1 of OOD: InteractionInteraction Diagrams Diagrams
Construct interaction diagrams for Construct interaction diagrams for eacheach scenario, focus is scenario, focus is on the objects and the on the objects and the messages passedmessages passed between them. between them. “Passing a message” between objects really means having
one object invoke a public member function of another object.
• An interaction is implemented by a group of objects that collaborate by exchanging messages.
• Two variants of UML Interaction Diagrams:
– Collaboration/Communication and
– Sequence Diagrams
O
bje
ct-O
rien
ted
Des
ign
3
*Collaboration Diagrams:*Collaboration Diagrams: spatialspatial representation representation
Focus is on the Focus is on the relationshipsrelationships between objects between objects Goal is to understand Structure of Design’s components Timing info is obscure, messages numbered to indicate
sending order
ExampleExample: Consider : Consider making a hotel reservationmaking a hotel reservation
O
bje
ct-O
rien
ted
Des
ign
4
Example: Elevator Example: Elevator CollaborationCollaboration Diagram Diagram
Sally is on the 10Sally is on the 10thth floor and presses a floor button. The floor and presses a floor button. The elevator arrives from the ground floor to pick her up.elevator arrives from the ground floor to pick her up.
O
bje
ct-O
rien
ted
Des
ign
5
*Sequence Diagrams:*Sequence Diagrams: temporaltemporal representation representation Focus is on message broadcast chronology of interactions Focus is on message broadcast chronology of interactions
between objects from a temporal standpoint. between objects from a temporal standpoint. An object is represented by a rectangle and a vertical bar. Message sending order indicated by position on axis.
Again, consider making Again, consider making a hotel reservationa hotel reservation
O
bje
ct-O
rien
ted
Des
ign
6
Example: Elevator Example: Elevator SequenceSequence Diagram Diagram
Sally is on the 10Sally is on the 10thth floor and presses a floor button. The floor and presses a floor button. The elevator arrives from the ground floor to pick her up.elevator arrives from the ground floor to pick her up.
O
bje
ct-O
rien
ted
Des
ign
7
Connection between Connection between ScenariosScenarios & & SequenceSequence Diagrams Diagrams
Example of a Normal Use Scenario
O
bje
ct-O
rien
ted
Des
ign
8
A UML A UML CollaborationCollaboration Diagram Diagram
A Collaboration Diagram is equivalent to its
corresponding Sequence Diagram
O
bje
ct-O
rien
ted
Des
ign
9
MFKA UML Sequence DiagramMFKA UML Sequence Diagram
ICE: Produce a UML Sequence Diagram for the Marine Marine Field Kitchen AssistantField Kitchen Assistant scenario of “Finding a recipe for chili that includes chipotle powder, scaling it for 200 Marines per meal, and generating a grocery list for a week’s worth of chili (to be eaten 3 times a day).”
O
bje
ct-O
rien
ted
Des
ign
10
*Step 2 of OOD*Step 2 of OOD: Construct : Construct DetailedDetailed Class Diagram Class Diagram
A well-structured Interaction Diagram gives very specific A well-structured Interaction Diagram gives very specific information on what responsibilities a class should have.information on what responsibilities a class should have.
Main question, do we assign an action to a class or to a Main question, do we assign an action to a class or to a client of that class? client of that class?
• Information hiding
• Reducing copies of an action
• Responsibility-driven design Examples
• close doors assigned to Elevator Doors
• move one floor down assigned to Elevator
Typical:Typical: Class at head of arrow on Interaction Diagram gets Class at head of arrow on Interaction Diagram gets tasked with the labeled responsibility, and implements it as a tasked with the labeled responsibility, and implements it as a method. method.
O
bje
ct-O
rien
ted
Des
ign
11
*Construct Detailed Class Diagram*Construct Detailed Class Diagram
Consider class Elevator Controller If User wants to log and update
requests, needs requests attribute Needs methods:
log request, update requests, request is pending
Detailed: As used here means that all method names, and (as a by-product) attributes ID’d by designer, are represented on the diagram
O
bje
ct-O
rien
ted
Des
ign
12
*Step 3 of OOD*Step 3 of OOD: Determine Clients of Objects: Determine Clients of Objects
Design Product in Terms of Clients of Objects to determine Design Product in Terms of Clients of Objects to determine which objects should create other objectswhich objects should create other objects Draw a single arrow from each object to a client of that object Objects that are not clients of any object have to be initiated,
probably upon system launch, Additional methods may be needed.
elevator controller needs method elevator control loop so that elevator application can call it.
This Completes High-Level Design for OOD!
O
bje
ct-O
rien
ted
Des
ign
13
*Step 4 of OOD:*Step 4 of OOD: Perform Detailed Design Perform Detailed Design Detailed design of method Detailed design of method
elevator controller loopelevator controller loop, draws , draws heavily from prior UML heavily from prior UML diagrams. Design Team:diagrams. Design Team:
Should not do too much:Should not do too much: Detailed design should not
become complete code Should not do too little:Should not do too little:
It is essential for detailed design to fully indicate how all functionality is met.
So, how to verify we are done So, how to verify we are done with detailed design? with detailed design?
O
bje
ct-O
rien
ted
Des
ign
14
*ICE: *ICE: Detailed Design Detailed Design Detailed design of method Detailed design of method
elevator controller loopelevator controller loop, draws , draws heavily from prior UML heavily from prior UML diagrams. Design Team:diagrams. Design Team:
Should not do too much:Should not do too much: Detailed design should not
become complete code Should not do too little:Should not do too little:
It is essential for detailed design to fully indicate how all functionality is met.
So, what should detailed So, what should detailed design’s output be? design’s output be?
ICE: Take an assigned class, andICE: Take an assigned class, and1. Complete the detailed UML
class diagram of assigned class (to include its methods and attributes), and
2. Give the pseudo-code for the most complex method in the class.
3. We will pick a QA volunteer to walk thru the chipotle chili scenario and make sure each class has the methods the sequence diagram expects of it.
O
bje
ct-O
rien
ted
Des
ign
15
*Testing During the Design Phase*Testing During the Design Phase
Design itself must be correctDesign itself must be correct No logic faults Interface for each class fully defined.
Design reviews. Purpose is to show that Design Design reviews. Purpose is to show that Design correctly reflects Specification. How can this be shown?correctly reflects Specification. How can this be shown?
O
bje
ct-O
rien
ted
Des
ign
16
*Case Tools for OOD*Case Tools for OOD
Computer Aided Software Engineering (CASE) toolsComputer Aided Software Engineering (CASE) tools Examples of CASE tools:
• Software through Pictures,
• Rational Rose
• Visual Paradigm Built around data dictionary Screen, report generators What automated support could be provided by a case tool
that represents OOD using UML?
O
bje
ct-O
rien
ted
Des
ign
17
*Metrics for OOD*Metrics for OOD
What Metrics can be used to describe various aspects of What Metrics can be used to describe various aspects of the Design? the Design?
One is McCabe’s Cyclomatic complexity. Measure based One is McCabe’s Cyclomatic complexity. Measure based on # of controlflow decisions, can apply to pseudo-code.on # of controlflow decisions, can apply to pseudo-code. the number of binary decisions plus 1, a metric of design quality, the lower the M the better
What other aspects of a Design can be Measured?What other aspects of a Design can be Measured?
• Advantage: Easy to compute, can be automated
• Disadvantage: Measures control complexity only, does not measure data complexity.