Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Reengineering Patterns-Patterns in Software Engineering-Lecture 14 Slides-Computer Engineering, Slides of Software Engineering

Reengineering Patterns, Detecting Duplicated Code, Visualize Code as Dotplots, Redistribute Responsibilities, Move Behavior Close to Data, Eliminate Navigation Code, Split Up God Class, Transform Self Type Checks, Transform Conditionals to Polymorphism, Factor Out State, Factor Out Strategy, Transform Conditionals to Polymorphism, Raman Ramsin, Lecture Slides, Patterns in Software Engineering, Department of Computer Engineering, Sharif University of Technology, Iran.

Typology: Slides

2011/2012

Uploaded on 02/19/2012

hester
hester 🇮🇷

4.5

(13)

85 documents

1 / 26

Toggle sidebar

Related documents


Partial preview of the text

Download Reengineering Patterns-Patterns in Software Engineering-Lecture 14 Slides-Computer Engineering and more Slides Software Engineering in PDF only on Docsity! Patterns in Software Engineering Lecturer: Raman Ramsin Lecture 14 Reengineering Patterns Part 2 Department of Computer Engineering 1 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Reengineering Patterns: Detecting Duplicated Code Department of Computer Engineering 2 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Visualize Code as Dotplots Department of Computer Engineering 5 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Reengineering Patterns: Redistribute Responsibilities Department of Computer Engineering 6 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Redistribute Responsibilities: Move Behavior Close to Data P bl H d f l f b iro em: ow o you trans orm a c ass rom e ng a mere data container into a real service provider? Solution: Move behavior defined by indirect clients to the t i f th d t hi h it tcon a ner o e a a on w c opera es. Department of Computer Engineering 7 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Eliminate Navigation Code Department of Computer Engineering 10 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Redistribute Responsibilities: Split Up God Class Problem: How do you maintain a class that assumes too ibiliti ?many respons es Solution: Incrementally redistribute the responsibilities of the god class either to its collaborating classes or to new classes that are pulled out of the god class. When there is nothing left of the god class but a facade, remove or d t th f depreca e e aca e. Department of Computer Engineering 11 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Split Up God Class Department of Computer Engineering 12 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Transform Self Type Checks Department of Computer Engineering 15 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Transform Conditionals to Polymorphism: Transform Client Type Checks Problem: Reducing the coupling between clients and providers of services, where the clients explicitly test the type of providers, and have the responsibility to compose providers' code. Solution: Introduce a new method into the provider hierarchy. Implement the new method in each subclass of the provider hierarchy by moving the corresponding case of the client's conditional to that class. Replace the entire conditional in the client by a simple call to the new method. Department of Computer Engineering 16 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Transform Client Type Checks Department of Computer Engineering 17 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Transform Conditionals to Polymorphism: Factor Out Strategy Problem: How do you make a class whose behavior depends i h l f i bl ibl ?on test ng t e va ue o some var a e more extens e Solution: Apply the Strategy pattern, that is, encapsulate the algorithmic dependent behavior into separate objects with polymorphic interfaces, and delegate calls to these objects. Department of Computer Engineering 20 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Factor Out Strategy Department of Computer Engineering 21 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Transform Conditionals to Polymorphism: Introduce Null Object Problem: How can you ease modification and extension of a class in the presence of repeated tests for null values? Solution: Apply Null Object, that is, encapsulate the null behavior as a separate provider class so that the client class does not have to perform a null test. Department of Computer Engineering 22 Sharif University of Technology Patterns in Software Engineering – Lecture 14 Transform Conditionals into Registration Department of Computer Engineering 25 Sharif University of Technology Patterns in Software Engineering – Lecture 14 R fe erence Demeyer S Ducasse S and Nierstrasz O Object-Oriented, ., , ., , ., Reengineering Patterns, Elsevier Science, 2003. Department of Computer Engineering 26 Sharif University of Technology