









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of refactoring patterns in software engineering as discussed in lecture 12 at sharif university of technology. Topics include dealing with generalization through techniques like pull up constructor body, extract subclass/superclass, extract interface, collapse hierarchy, form template method, replace inheritance with delegation, replace delegation with inheritance, tease apart inheritance, and convert procedural design to objects. Fowler's 'refactoring: improving the design of existing code' is recommended for further study.
Typology: Slides
1 / 17
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