SlideShare ist ein Scribd-Unternehmen logo
1 von 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 ?

Weitere ähnliche Inhalte

Ähnlich wie Refactoring

Ähnlich wie 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
 

Kürzlich hochgeladen

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
 
+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@
 
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
 

Kürzlich hochgeladen (20)

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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
+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...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

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 ?