SlideShare a Scribd company logo
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 ?

More Related Content

Similar to Refactoring

Bade Smells in Code
Bade Smells in CodeBade Smells in Code
Bade Smells in Code
Will Shen
 
Code smells
Code smellsCode smells
Code smells
Narayann Swaami
 
Speeding up web_application
Speeding up web_applicationSpeeding up web_application
Speeding up web_application
Achintya Kumar
 
Code Refactoring using rails
Code Refactoring using railsCode Refactoring using rails
Code Refactoring using rails
Achintya Kumar
 
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
Valerio Maggio
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smells
kim.mens
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
Charlie Berg
 
Code smells quality of code
Code smells   quality of codeCode smells   quality of code
Code smells quality of code
Hasan Al Mamun
 
Php traits
Php traitsPhp traits
Php traits
Shaun Morrow
 
Code Refactoring
Code RefactoringCode Refactoring
OOPSCA1.pptx
OOPSCA1.pptxOOPSCA1.pptx
OOPSCA1.pptx
Soumyadipchanda2
 
Bad Smells in Code
Bad Smells in CodeBad Smells in Code
Bad Smells in Code
Özge Nur KOÇ
 
OO Metrics
OO MetricsOO Metrics
OO Metrics
skmetz
 
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
 
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
04_-_Inheritance_Polymorphism_and_Interfaces.pdf04_-_Inheritance_Polymorphism_and_Interfaces.pdf
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
markbrianBautista
 
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
Rylan Cottrell
 
Software Craftsmanship - Code Smells - Bloaters
Software Craftsmanship - Code Smells - BloatersSoftware Craftsmanship - Code Smells - Bloaters
Software Craftsmanship - Code Smells - Bloaters
Rajat Singla
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
Perfomatix Solutions
 
Learn java lessons_online
Learn java lessons_onlineLearn java lessons_online
Learn java lessons_online
nishajj
 
Template pattern
Template patternTemplate pattern
Template pattern
Vithushan Vinayagamoorthy
 

Similar to 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
 

Recently uploaded

Things to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUUThings to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUU
FODUU
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 

Recently uploaded (20)

Things to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUUThings to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUU
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 

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 ?