15 Class Design
2006. 5. 17
Seok-Joong Woo
Contents
Introduction
Bridging the gap
Realizing use cases
Designing algorithms
Recursing downward
Refactoring
Design optimization
Reification of behavior
Adjustment of inheritance
Organizing a class design
Summary
2006-05-17 2/21
Introduction
Class design
Augment and adjust the real-world models from
analysis
• Complete the definition of the classes and
associations
• Choose algorithms for operation
2006-05-17 3/21
Bridging the gap
Desired features
Intermediate
The gap
elements ?
Available resources
2006-05-17 4/21
Realizing use cases
Purpose
Use cases define the required behavior without
realization
Design must invent new operations and new
object that provide this behavior
Steps
List the responsibilities of use case or operation
Define an operation for each responsibility
Assign the new low-level operations to classes
2006-05-17 5/21
Designing algorithms(1/2)
2006-05-17 6/21
Designing algorithms(2/2)
Steps(cont’d)
Choosing data structures
Defining internal classes and operations
Assigning operations to classes
• Receiver of action
• Query vs. update Person
User
친지 Vehicle
학생 Rectangle
선생님
Move
• Focal class 공부Resize
공부
공부
2006-05-17 7/21
Recursing downward(1/3)
2006-05-17 8/21
Recursing downward(3/3)
2006-05-17 9/21
Recursing downward(3/3)
Approach(cont’d)
Mechanism layers
• Build the system out of layer of needed support
mechanisms
– Such as data structures, algorithms
• Don’t show up high-level responsibilities of a system
but they are needed to make it all work
2006-05-17 10/21
Refactoring
2006-05-17 11/21
Design optimization(1/3)
2006-05-17 12/21
Design optimization(2/3)
/SpeaksLanguage
*
language *
Employs HasSkill
Company Person Skill
1 * * *
2006-05-17 13/21
Design optimization(3/3)
2006-05-17 14/21
Reification of behavior
2006-05-17 15/21
Adjustment of inheritance(1/2)
2006-05-17 16/21
Adjustment of inheritance(2/2)
List
Stack
push
pop
2006-05-17 17/21
Adjustment of inheritance(2/2)
Stack List
Recommended design
body:list{private} (with delegation)
add
push * 1 remove
pop first
last
2006-05-17 18/21
Organizing a class design(1/2)
Information hiding
Separate external specification from internal
implementation
Ways
• Limit the scope of class-model traversals
• Do not directly access foreign attributes
• Define interfaces at a high level of abstraction
• Hide external objects
• Avoid cascading method calls
2006-05-17 19/21
Organizing a class design(2/2)
Coherence of entities
Separate policy and implementation
• Policy
– Making of context-dependent decision
• Implementation
– Execution of fully-specified algorithms
Fine-tuning packages
2006-05-17 20/21
Summary
2006-05-17 21/21
Encapsulation
Abstraction
Information
hiding
2006-05-17
Dictionary of terms
2006-05-17