SlideShare a Scribd company logo
Anand Bait
Developer
Allerin Tech Pvt Ltd
Refactoring Code
 Making code better, may not be faster
 Better structured, better built
 More readable, more understandable
 Easy to work with
 Easy to add new features
 Easy to spot and fix bugs
 Keeping code in control
 Improving existing code
Contents
 Introduction to Refactoring
 Method-Level Refactoring
 Class and Condition Focused Refactoring
 Data Focused Refactoring
 Communication and High Level Refactoring
 Conclusion
What ‘REFACTORING’ is?
 Techniques of improving code that already exists
 No rules that anyone can blindly follow to improve
code
 Techniques of recognize issues as per consciousness
 Applied without thinking will be dangerous
What ‘REFACTORING’ is NOT?
 Not debugging
 Not adding feature
 Not changing observable behavior of code
 Not performance improving
Why to use?
When to use?
 Write – Scan – Refactor at the end : INCORRECT
 Write – Scan – Refactor regularly : CORRECT
 Code reviews
How to use?
Code smell
 Duplicated code
 Long methods
 Comments
 Doesn’t tell what to do but tells us what to notice
Method Level Refactoring
 Preparing to refactor
 Grouping refactorings together
 Using the Extract Method refactoring
 Extract Method with parameters and variables
 Common code smells for Extract Method
 Using IDEs for the Extract Method refactoring
 The Inline Method refactoring
 Refactorings that remove temps
 Refactorings that add temps
Preparing to refactor
 Requirement of automated testing vs manual testing
Grouping refactorings together
 Individual Method(name? parameters? Temp
variables? Duplicate? Too much in method?)
 Context of method in class (right class? similarity with
other methods class)
 Communication between classes(inheritance)
Extract Method refactoring
 Smaller and specific is better
 Provides reusability
 Ease of overriding while using inheritance
Extract Method with parameters
 Parameters should be related to the method
Extract Method with variables
 Temporary variables can be extracted
Code smells for using Extract
Method
 Long method
 Comments(having comments vs need comments)
Inline Method refactoring
 Removing method that adds no value
Refactoring to remove temps
 Increase temptation to write longer methods
 Change temps to small methods
Refactoring to add temps
 Split temporary variables
 Introduce explaining variables
 Remove assignments to parameters
Split temporary variables
 Don’t use same temporary variable for different
purposes
Introduce explaining variables
 To improve readability
 Introduce when a small method may not be required
Remove assignments to
parameters
 Add temporary variables that assigns value to
parameters may give undesired results
Class and Condition Focused
Refactoring
 Move Method
 Extract Class and Inline Class
 Making conditions easier to read
 Replacing conditions with polymorphism
 Replacing type code with subclasses
Move Method
 Move method from one class to another
 When a method interact with multiple classes then
move it to the class with which it interacts more
 Code smell: feature envy, inappropriate intimacy,
shotgun surgery
Extract Class and Inline Class
 Code smell: Large class
Making conditions easier to read
 Decompose conditionals
 Consolidate conditionals
 Consolidate duplicate conditionals
Replacing conditions with
polymorphism
 Conditions to check custom behavior
Replacing type code with
subclasses
 Data can be categorized into subclasses
Data Focused Refactoring
 Moving and encapsulating fields
 Working with data clumps
 Simplifying method calls and parameter use
 Pulling and pushing methods and fields
Moving and encapsulating fields
 If a field is more related and being used by the other
class
Working with data clumps
 Preserve whole object
(instead of parameters pass object)
 Introduce parameter object
(minimize parameters list by creating a class for set of
parameters)
Simplifying method calls and
parameter use
 Rename method
 Remove parameter
 Add parameter
 Parameterize method
(same behavior multiple methods)
 De-parameterize method
(same type of parameter but different behavior depending
on parameter)
 Separate Query from Modifier
(split method with individual focus on functioning)
Pulling and pushing methods and
fields
 Pull up method
 Pull up field
 Push down method
 Push down field
Communication and High-Level
Refactoring
 Refining hierarchies
Extract superclass, Extract subclass, collapse hierarchy
 Communication refactoring
Code smell: message chain, middle man
 Larger scale refactoring
Convert procedural to OO
Code smell: large classes, god classes, dumb data
Conclusion
References
 http://refactoring.com
Thank you

More Related Content

Similar to Code Refactoring using rails

Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
Charlie Berg
 
Reduce Reuse Refactor
Reduce Reuse RefactorReduce Reuse Refactor
Reduce Reuse Refactor
Alena Holligan
 
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif IqbalCode Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Cefalo
 
Lecture: Refactoring
Lecture: RefactoringLecture: Refactoring
Lecture: Refactoring
Marcus Denker
 
Code Refactoring - 3.0
Code Refactoring - 3.0Code Refactoring - 3.0
Code Refactoring - 3.0
Arul Prakash
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기
Myeongseok Baek
 
The Nature Of Patterns
The Nature Of PatternsThe Nature Of Patterns
The Nature Of Patterns
Nick Harrison
 
Behavioral design patterns presentation
Behavioral design patterns presentationBehavioral design patterns presentation
Behavioral design patterns presentation
Mina Ayoub
 
Software Craftsmanship - Code Smells - Bloaters
Software Craftsmanship - Code Smells - BloatersSoftware Craftsmanship - Code Smells - Bloaters
Software Craftsmanship - Code Smells - Bloaters
Rajat Singla
 
SF1 - Apex Development Best Practises
SF1 - Apex Development Best PractisesSF1 - Apex Development Best Practises
SF1 - Apex Development Best Practises
Sebastian Wagner
 
OOPSCA1.pptx
OOPSCA1.pptxOOPSCA1.pptx
OOPSCA1.pptx
Soumyadipchanda2
 
Code Refactoring Cheatsheet
Code Refactoring CheatsheetCode Refactoring Cheatsheet
Code Refactoring Cheatsheet
Rachanee Saengkrajai
 
Resharper - Next Steps
Resharper - Next StepsResharper - Next Steps
Resharper - Next Steps
Timmy Kokke
 
Introduction to Refactoring
Introduction to RefactoringIntroduction to Refactoring
Introduction to Refactoring
Vorleak Chy
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smells
kim.mens
 
Bad Smell In Codes 1
Bad Smell In Codes 1Bad Smell In Codes 1
Bad Smell In Codes 1
A Walk in the World
 
Abcxyz
AbcxyzAbcxyz
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
DevDay.org
 
Code smell overview
Code smell overviewCode smell overview
Code smell overview
Pham Manh Lan
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
Perfomatix Solutions
 

Similar to Code Refactoring using rails (20)

Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Reduce Reuse Refactor
Reduce Reuse RefactorReduce Reuse Refactor
Reduce Reuse Refactor
 
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif IqbalCode Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
 
Lecture: Refactoring
Lecture: RefactoringLecture: Refactoring
Lecture: Refactoring
 
Code Refactoring - 3.0
Code Refactoring - 3.0Code Refactoring - 3.0
Code Refactoring - 3.0
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기
 
The Nature Of Patterns
The Nature Of PatternsThe Nature Of Patterns
The Nature Of Patterns
 
Behavioral design patterns presentation
Behavioral design patterns presentationBehavioral design patterns presentation
Behavioral design patterns presentation
 
Software Craftsmanship - Code Smells - Bloaters
Software Craftsmanship - Code Smells - BloatersSoftware Craftsmanship - Code Smells - Bloaters
Software Craftsmanship - Code Smells - Bloaters
 
SF1 - Apex Development Best Practises
SF1 - Apex Development Best PractisesSF1 - Apex Development Best Practises
SF1 - Apex Development Best Practises
 
OOPSCA1.pptx
OOPSCA1.pptxOOPSCA1.pptx
OOPSCA1.pptx
 
Code Refactoring Cheatsheet
Code Refactoring CheatsheetCode Refactoring Cheatsheet
Code Refactoring Cheatsheet
 
Resharper - Next Steps
Resharper - Next StepsResharper - Next Steps
Resharper - Next Steps
 
Introduction to Refactoring
Introduction to RefactoringIntroduction to Refactoring
Introduction to Refactoring
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smells
 
Bad Smell In Codes 1
Bad Smell In Codes 1Bad Smell In Codes 1
Bad Smell In Codes 1
 
Abcxyz
AbcxyzAbcxyz
Abcxyz
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
 
Code smell overview
Code smell overviewCode smell overview
Code smell overview
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
 

More from Achintya Kumar

Clean code
Clean code Clean code
Clean code
Achintya Kumar
 
Speeding up web_application
Speeding up web_applicationSpeeding up web_application
Speeding up web_application
Achintya Kumar
 
Introduction to-angular js
Introduction to-angular jsIntroduction to-angular js
Introduction to-angular js
Achintya Kumar
 
Rails best practices
Rails best practicesRails best practices
Rails best practices
Achintya Kumar
 
Application lifecycle management
Application lifecycle managementApplication lifecycle management
Application lifecycle management
Achintya Kumar
 
Graph database
Graph databaseGraph database
Graph database
Achintya Kumar
 

More from Achintya Kumar (6)

Clean code
Clean code Clean code
Clean code
 
Speeding up web_application
Speeding up web_applicationSpeeding up web_application
Speeding up web_application
 
Introduction to-angular js
Introduction to-angular jsIntroduction to-angular js
Introduction to-angular js
 
Rails best practices
Rails best practicesRails best practices
Rails best practices
 
Application lifecycle management
Application lifecycle managementApplication lifecycle management
Application lifecycle management
 
Graph database
Graph databaseGraph database
Graph database
 

Recently uploaded

socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 

Recently uploaded (20)

socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 

Code Refactoring using rails

  • 2. Refactoring Code  Making code better, may not be faster  Better structured, better built  More readable, more understandable  Easy to work with  Easy to add new features  Easy to spot and fix bugs  Keeping code in control  Improving existing code
  • 3. Contents  Introduction to Refactoring  Method-Level Refactoring  Class and Condition Focused Refactoring  Data Focused Refactoring  Communication and High Level Refactoring  Conclusion
  • 4. What ‘REFACTORING’ is?  Techniques of improving code that already exists  No rules that anyone can blindly follow to improve code  Techniques of recognize issues as per consciousness  Applied without thinking will be dangerous
  • 5. What ‘REFACTORING’ is NOT?  Not debugging  Not adding feature  Not changing observable behavior of code  Not performance improving
  • 7. When to use?  Write – Scan – Refactor at the end : INCORRECT  Write – Scan – Refactor regularly : CORRECT  Code reviews How to use?
  • 8. Code smell  Duplicated code  Long methods  Comments  Doesn’t tell what to do but tells us what to notice
  • 9. Method Level Refactoring  Preparing to refactor  Grouping refactorings together  Using the Extract Method refactoring  Extract Method with parameters and variables  Common code smells for Extract Method  Using IDEs for the Extract Method refactoring  The Inline Method refactoring  Refactorings that remove temps  Refactorings that add temps
  • 10. Preparing to refactor  Requirement of automated testing vs manual testing
  • 11. Grouping refactorings together  Individual Method(name? parameters? Temp variables? Duplicate? Too much in method?)  Context of method in class (right class? similarity with other methods class)  Communication between classes(inheritance)
  • 12. Extract Method refactoring  Smaller and specific is better  Provides reusability  Ease of overriding while using inheritance
  • 13. Extract Method with parameters  Parameters should be related to the method Extract Method with variables  Temporary variables can be extracted
  • 14. Code smells for using Extract Method  Long method  Comments(having comments vs need comments)
  • 15. Inline Method refactoring  Removing method that adds no value
  • 16. Refactoring to remove temps  Increase temptation to write longer methods  Change temps to small methods
  • 17. Refactoring to add temps  Split temporary variables  Introduce explaining variables  Remove assignments to parameters
  • 18. Split temporary variables  Don’t use same temporary variable for different purposes
  • 19. Introduce explaining variables  To improve readability  Introduce when a small method may not be required
  • 20. Remove assignments to parameters  Add temporary variables that assigns value to parameters may give undesired results
  • 21. Class and Condition Focused Refactoring  Move Method  Extract Class and Inline Class  Making conditions easier to read  Replacing conditions with polymorphism  Replacing type code with subclasses
  • 22. Move Method  Move method from one class to another  When a method interact with multiple classes then move it to the class with which it interacts more  Code smell: feature envy, inappropriate intimacy, shotgun surgery
  • 23. Extract Class and Inline Class  Code smell: Large class
  • 24. Making conditions easier to read  Decompose conditionals  Consolidate conditionals  Consolidate duplicate conditionals
  • 25. Replacing conditions with polymorphism  Conditions to check custom behavior
  • 26. Replacing type code with subclasses  Data can be categorized into subclasses
  • 27. Data Focused Refactoring  Moving and encapsulating fields  Working with data clumps  Simplifying method calls and parameter use  Pulling and pushing methods and fields
  • 28. Moving and encapsulating fields  If a field is more related and being used by the other class
  • 29. Working with data clumps  Preserve whole object (instead of parameters pass object)  Introduce parameter object (minimize parameters list by creating a class for set of parameters)
  • 30. Simplifying method calls and parameter use  Rename method  Remove parameter  Add parameter  Parameterize method (same behavior multiple methods)  De-parameterize method (same type of parameter but different behavior depending on parameter)  Separate Query from Modifier (split method with individual focus on functioning)
  • 31. Pulling and pushing methods and fields  Pull up method  Pull up field  Push down method  Push down field
  • 32. Communication and High-Level Refactoring  Refining hierarchies Extract superclass, Extract subclass, collapse hierarchy  Communication refactoring Code smell: message chain, middle man  Larger scale refactoring Convert procedural to OO Code smell: large classes, god classes, dumb data