









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










1
Sharif University of Technology
Pull Up Constructor Body
Pull
Up Constructor Body
^
Pull Up Constructor Body^ ^
You have constructors on subclasses with mostly identical bodies. Create a superclass constructor; call this from the subclass methods.
2
Sharif University of Technology
Extract Interface
Extract
Interface
^
Extract Interface^ ^
Several clients use the same subset of a class's interface, or two classes havepart of their interfaces in common. Extract the subset into an interface.
4
Sharif University of Technology
Collapse Hierarchy
Collapse
Hierarchy
^
Collapse Hierarchy ^
Collapse
Hierarchy
^ A superclass and subclass are not very different. ^ Merge them together.
5
Sharif University of Technology
Form Template Method
Form
Template Method
7
Sharif University of Technology
Patterns in Software Engineering – Lecture 12 Dealing with Generalization:
Replace Inheritance with Delegation
g^
p^
g
^
Replace Inheritance with Delegation p^
g
^ A subclass uses only part of a superclass’s interface or does not want to inheritdata. ^ Create a field for the superclass
adjust methods to delegate to the superclass
^ Create a field for the superclass, adjust methods to delegate to the superclass,and remove the subclassing.
8
Sharif University of Technology
Tease Apart Inheritance
Tease
Apart Inheritance
^
Tease Apart InheritanceTease
Apart Inheritance
^ You have an inheritance hierarchy that is doing two jobs at ^ You
have an inheritance hierarchy that is doing two jobs at
Create two hierarchies and use delegation to invoke onefrom the other.
10
Sharif University of Technology
Tease Apart Inheritance
Tease
Apart Inheritance 11
Sharif University of Technology
Convert Procedural Design to Objects
Convert
Procedural Design to Objects 13
Sharif University of Technology
Separate Domain from Presentation
Separate
Domain from Presentation
^
Separate Domain from Presentation ^
Separate
Domain from Presentation
^ You have GUI classes that contain domain logic. ^ Separate the domain logic into separate domain classes.
14
Sharif University of Technology
Extract Hierarchy
Extract
Hierarchy 16
Sharif University of Technology
Addison-Wesley, 1999.
17
Sharif University of Technology