SlideShare uma empresa Scribd logo
1 de 15
Refactoring Prepared by YuriySeniuk
Software evolution
Causes for refactoring Code duplicating; Huge method; Huge or deep loops; Bad class coherency;  Bad interface agreement (Interface monster); Too many parameters in method; Too much class’s responsibilities;
Causes for refactoring It’s necessary to make changes in several classes; It’s necessary to change several hierarchies; It’s necessary to make changes in several case blocks; Coherent data placed not in a class; Method use more parameters from other class than its; Elementary type is overload;
Causes for refactoring Class has limited functionality; Method gets Tramp data; One class knows too much about another one; Method has unlucky name; Public fields; Inherited class used small dime of base methods; Code Comments; Class contains methods that could be some time;
Data Refactoring Magic numbers; Unlucky variable name;  Temporary variable using; Multiple usage of the same variable; Enum usage; Basic type expansion;
Operator Refactoring Decomposition of expression; Extract Boolean methods; Immediate exit from method; Polymorphism usage; Dummy objects usage;
Methods Refactoring Method extraction; Inline method; Class extraction from huge methods; Additional parameters usage; Redundant parameters deletion;  Pass whole class instead of several parameters; Return base classes;
Class Refactoring Value to Reference types replacement; Reference to Value types replacement; Move fields/properties/methods to base class; Move fields/properties/methods to inherited class; Move methods to another class; Split one class to many; Delete useless class; Use extension methods;
Class Refactoring Replace inheritance to delegating; Replace delegating to inheritance; Data encapsulating; Unite inherited and base class.
Safe Refactoring Save original code; Make refactoring step-by-step; Create list of actions; Create To-Do list; Create check points; Monitor warnings from compiler; Make change-reviews.
Bad causes to do refactoring Do not expect refactoring to correct your code; Do not wait for some magic from refactoring.
Refactoring strategies Use refactoring when you: Create new methods; Create new classes; Fix defects; Create refactoring in bug’s potential code; Create refactoring in complicated modules.
Refactoring strategies
Q&A ?

Mais conteúdo relacionado

Semelhante a Refactoring

Semelhante a Refactoring (20)

Bade Smells in Code
Bade Smells in CodeBade Smells in Code
Bade Smells in Code
 
Code smells
Code smellsCode smells
Code smells
 
Speeding up web_application
Speeding up web_applicationSpeeding up web_application
Speeding up web_application
 
Code Refactoring using rails
Code Refactoring using railsCode Refactoring using rails
Code Refactoring using rails
 
Refactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeRefactoring: Improve the design of existing code
Refactoring: Improve the design of existing code
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smells
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Code smells quality of code
Code smells   quality of codeCode smells   quality of code
Code smells quality of code
 
Php traits
Php traitsPhp traits
Php traits
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
OOPSCA1.pptx
OOPSCA1.pptxOOPSCA1.pptx
OOPSCA1.pptx
 
Bad Smells in Code
Bad Smells in CodeBad Smells in Code
Bad Smells in Code
 
OO Metrics
OO MetricsOO Metrics
OO Metrics
 
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
 
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
04_-_Inheritance_Polymorphism_and_Interfaces.pdf04_-_Inheritance_Polymorphism_and_Interfaces.pdf
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
 
The End-to-End Use of Source Code Example: An Exploratory Study ICSM'09
The End-to-End Use of Source Code Example: An Exploratory Study  ICSM'09The End-to-End Use of Source Code Example: An Exploratory Study  ICSM'09
The End-to-End Use of Source Code Example: An Exploratory Study ICSM'09
 
Software Craftsmanship - Code Smells - Bloaters
Software Craftsmanship - Code Smells - BloatersSoftware Craftsmanship - Code Smells - Bloaters
Software Craftsmanship - Code Smells - Bloaters
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
 
Learn java lessons_online
Learn java lessons_onlineLearn java lessons_online
Learn java lessons_online
 
Template pattern
Template patternTemplate pattern
Template pattern
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Refactoring

  • 3. Causes for refactoring Code duplicating; Huge method; Huge or deep loops; Bad class coherency; Bad interface agreement (Interface monster); Too many parameters in method; Too much class’s responsibilities;
  • 4. Causes for refactoring It’s necessary to make changes in several classes; It’s necessary to change several hierarchies; It’s necessary to make changes in several case blocks; Coherent data placed not in a class; Method use more parameters from other class than its; Elementary type is overload;
  • 5. Causes for refactoring Class has limited functionality; Method gets Tramp data; One class knows too much about another one; Method has unlucky name; Public fields; Inherited class used small dime of base methods; Code Comments; Class contains methods that could be some time;
  • 6. Data Refactoring Magic numbers; Unlucky variable name; Temporary variable using; Multiple usage of the same variable; Enum usage; Basic type expansion;
  • 7. Operator Refactoring Decomposition of expression; Extract Boolean methods; Immediate exit from method; Polymorphism usage; Dummy objects usage;
  • 8. Methods Refactoring Method extraction; Inline method; Class extraction from huge methods; Additional parameters usage; Redundant parameters deletion; Pass whole class instead of several parameters; Return base classes;
  • 9. Class Refactoring Value to Reference types replacement; Reference to Value types replacement; Move fields/properties/methods to base class; Move fields/properties/methods to inherited class; Move methods to another class; Split one class to many; Delete useless class; Use extension methods;
  • 10. Class Refactoring Replace inheritance to delegating; Replace delegating to inheritance; Data encapsulating; Unite inherited and base class.
  • 11. Safe Refactoring Save original code; Make refactoring step-by-step; Create list of actions; Create To-Do list; Create check points; Monitor warnings from compiler; Make change-reviews.
  • 12. Bad causes to do refactoring Do not expect refactoring to correct your code; Do not wait for some magic from refactoring.
  • 13. Refactoring strategies Use refactoring when you: Create new methods; Create new classes; Fix defects; Create refactoring in bug’s potential code; Create refactoring in complicated modules.
  • 15. Q&A ?