Title: AN OVERVIEW OF OBJECT ORIENTED DESIGN HEURISTICS
1AN OVERVIEW OF OBJECT ORIENTED DESIGN HEURISTICS
- M.Sc Thesis
- Author Muhammad K. Bashar Molla
- Email ens03mbr_at_cs.umu.se
- Supervisor Jurgen Börstler
- Email jubo_at_cs.umu.se
2Agenda
- Introduction
- Object Oriented Concepts
- Support For Object Oriented Design
- Existing Heuristics Design Models
- Relationship Between Heuristics Patterns
- Comparison of Heuristics
- Conflicting Heuristics
- Discussion
3Introduction
- What is Heuristic
- Why Heuristics
- How to collect Heuristics
4Object Oriented Concepts
- Object
- Class
- Inheritance
- Polymorphism
- Data abstraction Information hiding
- Encapsulation
- ...
5Support For OO Design
General Specfic
Methods Principles/Guidelines Heuristics/Rule
s OO Design Patterns
Process level (Design Process) Concrete
Design Problem
6Support For OO Design
Software Development Methods
OO Design Principles OO Design Patterns
OOD Heuristics Riel TOAD MeTHOOD Meyers ...
Object Oriented Design
7Existing Heuristics Design Models
- Riels Heuristics
- TOAD (Teaching Object-Oriented Analysis and
Design) Heuristics - MeTHOOD (Measures, Transformation Rules, and
Heuristics for Object-Oriented Design) Heuristics - Meyers Heuristics
8Existing Heuristics Design Models
Riels Heuristics Categories
- Class and Object (11 Heuristics)
- GOD Class (10 Heuristics)
- Different relationship (37 Heuristics)
- Class-specific and data behaviour (1 Heuristic)
- Physical Object-Oriented Design (2 Heuristics)
9Riels Heuristics
Heuristic Users of a class must be dependent on
its public interface, but a class should not be
dependent on its users
AnAlarmClock
ATimeClockSafe
AnAlarmClock
Person
John Umeå
CurrentTime 1140 AlarmTime 1230 AlarmStatus on
AlarmTime 0745 Meeting
CurrentTime 0515 AlarmTime 0745 AlarmStatus off
alarm_on()
alarm_off()
10Existing Heuristics Design Models
Riels Heuristics Categories
- Class and Object
- GOD Class (10 Heuristics)
- Different relationship (37 Heuristics)
- Class-specific and data behaviour (1 Heuristic)
- Physical Object-Oriented Design (2 Heuristics)
11Riels Heuristics
Heuristic Do not create god class/object in your
system
desired_temp? ()
Desired Temp
actual_temp? ()
HeatFlowRegulator
Furnace
Actual Temp
Occupancy
any_one_in_room? ()
Room
get_desired_temp ()
Desired Temp
get_actual_temp ()
HeatFlowRegulator
Furnace
Actual Temp
is_occupied ()
Occupancy
Room
do_you_need_heat? ()
Desired Temp
HeatFlowRegulator
Furnace
Actual Temp
Occupancy
12Existing Heuristics Design Models
Riels Heuristics Categories
- Class and Object
- GOD Class
- Different relationship (37 Heuristics)
- Class-specific and data behaviour (1 Heuristic)
- Physical Object-Oriented Design (2 Heuristics)
13Riels Heuristics
Heuristic Minimize the number of classes with
which another class collaborates
Meal
Melon
cost ()
Melon
cost ()
cost ()
Restaurant Patron
Steak
Resturant Patron
Steak
cost ()
Pie
Pie
14Existing Heuristics Design Models
Riels Heuristics Categories
- Class and Object
- GOD Class
- Different relationship (37 Heuristics)
continue... - Class-specific and data behaviour (1 Heuristic)
- Physical Object-Oriented Design (2 Heuristics)
15Riels Heuristics
Heuristic Do not confuse optional containment
with the need for inheritance, modeling optional
containment with inheritance will lead to a
proliferation of classes.
House
etc...
HeatingHouse
CoolingHouse
ElectricalHouse
HeatingCoolinhHouse
HeatingHouse
CoolingHouse
House
ElectricalHouse
etc...
16Existing Heuristics Design Models
- Riels Heuristics
- TOAD (Teaching Object-Oriented Analysis and
Design) Heuristics - MeTHOOD (Measures, Transformation Rules, and
Heuristics for Object-Oriented Design) Heuristics - Meyers Heuristics
17TOAD Heuristics
Heuristic Inheritance hierarchy root should be
abstract.
NewStudent Name ID Course ()
FullStudent AccessCard LBCard
FullStudent AccessCard LBCard
Student Name ID Course ()
NewStudent Name ID Course ()
18Existing Heuristics Design Models
- Riels Heuristics
- TOAD (Teaching Object-Oriented Analysis and
Design) Heuristics - MeTHOOD (Measures, Transformation Rules, and
Heuristics for Object-Oriented Design) Heuristics - Meyers Heuristics
19MeTHOOD Heuristics
Heuristic A class should capture one and only one
key abstraction with all its information and all
its behavior.
StudentProfile ID Name Address Result
20Exixting Heuristics Design Models
- Riels Heuristics
- TOAD (Teaching Object-Oriented Analysis and
Design) Heuristics - MeTHOOD (Measures, Transformation Rules, and
Heuristics for Object-Oriented Design) Heuristics - Meyers Heuristics
21Relationship Between Heuristics Patterns
- Singleton Pattern
- Observer Pattern
- ...
- Do not create god classes/objects in your system
- Minimize the number of classes with which another
class collaborates - ...
22Comparison of Heuristics
23Comparison of Heuristics
Most Similar Heuristics
24Conflicting Heuristics
Heuristic All base class should be abstract
Heuristic Eliminate irrelevant classes from your
design
Heuristic Do not exclude behavior from
subclasses
Bird move ( ) ...
Bird fly ( ) ...
Do not exclude behaviour from subclass
move ( )
Penguin fly ( ) no op
FlyingBird fly ( ) ... move ( )
Penguin swim ( ) ... move ( )
Eliminate irrelavent classes from your design
25Discussion
- No summary or conclusion ? So...
- Need more heuristics. How to ?
26Thanks
27Question???