SlideShare a Scribd company logo
1 of 7
When to refactor
And when to stop
Good, clean code is ready for change.
If the code is good enough to change, there’s probably no refactor needed
Refactoring is the practice of breaking up code or logic in preparation for change.
Refactor before you make a change to the code:
● Add tests to make concrete the logic
● Simplify or clarify the logic
● Uniform the business language
● Change the data model so it easy to modify
Refactoring after a change is made is Clean up.
Why Refactoring
What is not refactoring
Refactoring is not "gardening", or "grooming".
Refactoring is not cleanup
Refactor is not a rewrite
Refactoring keeps the existing process in place and keeps existing contracts.
Grooming the code for solving a more generalised problem may drive us to make
incorrect choices for the future
Refactoring steps
1. Add tests to make concrete the current logic, make the code testable enough
2. Run the tests: green result
3. Refactor the code
4. Rerun the tests: correct till green result
5. Repeat till code is simple “enough”
6. Ready to make logic changes
I can stop whenever I want!
Stop refactoring when the logical unit is "small enough".
Small enough?
To easily reuse?
To easily test?
To easily change?
To easily extend?
Refactoring steps have upper and lower limits, usually in the current logic unit. Do not "go deep".
Refactor only the immediate unit so that the change is small enough to easily test
refactored

More Related Content

What's hot

Skills Week / Chris Ambler / Quality Not Bugs
Skills Week / Chris Ambler / Quality Not BugsSkills Week / Chris Ambler / Quality Not Bugs
Skills Week / Chris Ambler / Quality Not Bugspixellab
 
Test & measurement; importance of test and measurement in electronics; measur...
Test & measurement; importance of test and measurement in electronics; measur...Test & measurement; importance of test and measurement in electronics; measur...
Test & measurement; importance of test and measurement in electronics; measur...SHIV DUTT
 
Automation pyramid within CI process
Automation pyramid within CI processAutomation pyramid within CI process
Automation pyramid within CI processUP2IT
 
Managing customer complaints
Managing customer complaintsManaging customer complaints
Managing customer complaintsJerry Bark
 
5.4 Product Spotlight: Email Upgrades
5.4 Product Spotlight: Email Upgrades5.4 Product Spotlight: Email Upgrades
5.4 Product Spotlight: Email UpgradesTargetX
 
Test Missions as Requirements
Test Missions as RequirementsTest Missions as Requirements
Test Missions as RequirementsJohan Hoberg
 
Tester performance evaluation
Tester performance evaluationTester performance evaluation
Tester performance evaluationgaoliang641
 
How The Zebra Utilized Feature Experiments To Increase Carrier Card Engagemen...
How The Zebra Utilized Feature Experiments To Increase Carrier Card Engagemen...How The Zebra Utilized Feature Experiments To Increase Carrier Card Engagemen...
How The Zebra Utilized Feature Experiments To Increase Carrier Card Engagemen...Optimizely
 
Value engineering _2_
Value engineering _2_Value engineering _2_
Value engineering _2_Swetlina .
 
Arun Dutta: Digital Performance Monitoring
Arun Dutta: Digital Performance MonitoringArun Dutta: Digital Performance Monitoring
Arun Dutta: Digital Performance MonitoringAnna Royzman
 
GRE - Computer Based Test
GRE - Computer Based TestGRE - Computer Based Test
GRE - Computer Based TestExoticHedge
 
Root cause analysis for incidents (or production defects)
Root cause analysis for incidents (or production defects)Root cause analysis for incidents (or production defects)
Root cause analysis for incidents (or production defects)Neha B
 
Test Automation Beyond Test Execution
Test Automation Beyond Test ExecutionTest Automation Beyond Test Execution
Test Automation Beyond Test ExecutionEggplant
 
Tech Talk #4 : Tester : Job finds resources - Trần Lệ Khuyên
Tech Talk #4 : Tester : Job finds resources - Trần Lệ KhuyênTech Talk #4 : Tester : Job finds resources - Trần Lệ Khuyên
Tech Talk #4 : Tester : Job finds resources - Trần Lệ KhuyênNexus FrontierTech
 

What's hot (18)

Week 02
Week 02Week 02
Week 02
 
Skills Week / Chris Ambler / Quality Not Bugs
Skills Week / Chris Ambler / Quality Not BugsSkills Week / Chris Ambler / Quality Not Bugs
Skills Week / Chris Ambler / Quality Not Bugs
 
Test & measurement; importance of test and measurement in electronics; measur...
Test & measurement; importance of test and measurement in electronics; measur...Test & measurement; importance of test and measurement in electronics; measur...
Test & measurement; importance of test and measurement in electronics; measur...
 
Automation pyramid within CI process
Automation pyramid within CI processAutomation pyramid within CI process
Automation pyramid within CI process
 
Managing customer complaints
Managing customer complaintsManaging customer complaints
Managing customer complaints
 
5.4 Product Spotlight: Email Upgrades
5.4 Product Spotlight: Email Upgrades5.4 Product Spotlight: Email Upgrades
5.4 Product Spotlight: Email Upgrades
 
Test Missions as Requirements
Test Missions as RequirementsTest Missions as Requirements
Test Missions as Requirements
 
Tester performance evaluation
Tester performance evaluationTester performance evaluation
Tester performance evaluation
 
How The Zebra Utilized Feature Experiments To Increase Carrier Card Engagemen...
How The Zebra Utilized Feature Experiments To Increase Carrier Card Engagemen...How The Zebra Utilized Feature Experiments To Increase Carrier Card Engagemen...
How The Zebra Utilized Feature Experiments To Increase Carrier Card Engagemen...
 
Value engineering _2_
Value engineering _2_Value engineering _2_
Value engineering _2_
 
PMP Exam Sample Questions Set 7
PMP Exam Sample Questions Set 7PMP Exam Sample Questions Set 7
PMP Exam Sample Questions Set 7
 
Arun Dutta: Digital Performance Monitoring
Arun Dutta: Digital Performance MonitoringArun Dutta: Digital Performance Monitoring
Arun Dutta: Digital Performance Monitoring
 
LO4 - Lesson 2 - Feedback
LO4 - Lesson 2 - FeedbackLO4 - Lesson 2 - Feedback
LO4 - Lesson 2 - Feedback
 
GRE - Computer Based Test
GRE - Computer Based TestGRE - Computer Based Test
GRE - Computer Based Test
 
TDD with RSpec
TDD with RSpecTDD with RSpec
TDD with RSpec
 
Root cause analysis for incidents (or production defects)
Root cause analysis for incidents (or production defects)Root cause analysis for incidents (or production defects)
Root cause analysis for incidents (or production defects)
 
Test Automation Beyond Test Execution
Test Automation Beyond Test ExecutionTest Automation Beyond Test Execution
Test Automation Beyond Test Execution
 
Tech Talk #4 : Tester : Job finds resources - Trần Lệ Khuyên
Tech Talk #4 : Tester : Job finds resources - Trần Lệ KhuyênTech Talk #4 : Tester : Job finds resources - Trần Lệ Khuyên
Tech Talk #4 : Tester : Job finds resources - Trần Lệ Khuyên
 

Similar to When to refactor

01- Lecture -Introduction to IT Agile Development.
01- Lecture -Introduction to IT Agile Development.01- Lecture -Introduction to IT Agile Development.
01- Lecture -Introduction to IT Agile Development.mailtoahmedhassan
 
[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
 
Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Editionjexp
 
The Power Of Refactoring (php|tek 09)
The Power Of Refactoring (php|tek 09)The Power Of Refactoring (php|tek 09)
The Power Of Refactoring (php|tek 09)Stefan Koopmanschap
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019Paulo Clavijo
 
How to successfully grow a code review culture
How to successfullygrow a code review cultureHow to successfullygrow a code review culture
How to successfully grow a code review cultureDanylenko Max
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop Itzik Saban
 
WHY MOODLE PLUGIN DEVELOPMENT NEEDS APPROVAL
WHY MOODLE PLUGIN DEVELOPMENT NEEDS APPROVALWHY MOODLE PLUGIN DEVELOPMENT NEEDS APPROVAL
WHY MOODLE PLUGIN DEVELOPMENT NEEDS APPROVALAditi Sharma
 
Ds02 flow chart and pseudo code
Ds02 flow chart and pseudo codeDs02 flow chart and pseudo code
Ds02 flow chart and pseudo codejyoti_lakhani
 
agile refactoring and integration techniques.pdf
agile refactoring and integration techniques.pdfagile refactoring and integration techniques.pdf
agile refactoring and integration techniques.pdfshreyassoni7
 
Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in RefactoringChamnap Chhorn
 
The Essentials Of Test Driven Development
The Essentials Of Test Driven Development The Essentials Of Test Driven Development
The Essentials Of Test Driven Development Rock Interview
 

Similar to When to refactor (20)

Refactoring
RefactoringRefactoring
Refactoring
 
Refactoring
RefactoringRefactoring
Refactoring
 
Code quality
Code quality Code quality
Code quality
 
SAD10 - Refactoring
SAD10 - RefactoringSAD10 - Refactoring
SAD10 - Refactoring
 
sCode optimization
sCode optimizationsCode optimization
sCode optimization
 
01- Lecture -Introduction to IT Agile Development.
01- Lecture -Introduction to IT Agile Development.01- Lecture -Introduction to IT Agile Development.
01- Lecture -Introduction to IT Agile Development.
 
[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,...
 
Reduce Reuse Refactor
Reduce Reuse RefactorReduce Reuse Refactor
Reduce Reuse Refactor
 
Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Edition
 
The Power Of Refactoring (php|tek 09)
The Power Of Refactoring (php|tek 09)The Power Of Refactoring (php|tek 09)
The Power Of Refactoring (php|tek 09)
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
 
How to successfully grow a code review culture
How to successfullygrow a code review cultureHow to successfullygrow a code review culture
How to successfully grow a code review culture
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
 
WHY MOODLE PLUGIN DEVELOPMENT NEEDS APPROVAL
WHY MOODLE PLUGIN DEVELOPMENT NEEDS APPROVALWHY MOODLE PLUGIN DEVELOPMENT NEEDS APPROVAL
WHY MOODLE PLUGIN DEVELOPMENT NEEDS APPROVAL
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
 
Ds02 flow chart and pseudo code
Ds02 flow chart and pseudo codeDs02 flow chart and pseudo code
Ds02 flow chart and pseudo code
 
agile refactoring and integration techniques.pdf
agile refactoring and integration techniques.pdfagile refactoring and integration techniques.pdf
agile refactoring and integration techniques.pdf
 
Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in Refactoring
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
The Essentials Of Test Driven Development
The Essentials Of Test Driven Development The Essentials Of Test Driven Development
The Essentials Of Test Driven Development
 

More from Yonni Mendes

Debriefing and post-mortems
Debriefing and post-mortemsDebriefing and post-mortems
Debriefing and post-mortemsYonni Mendes
 
Estimations and confidence
Estimations and confidenceEstimations and confidence
Estimations and confidenceYonni Mendes
 
Agile & What I know about it
Agile & What I know about itAgile & What I know about it
Agile & What I know about itYonni Mendes
 
Apigility & Restfull APIs
Apigility & Restfull APIsApigility & Restfull APIs
Apigility & Restfull APIsYonni Mendes
 
Zend server 6 using zf2, 2013 webinar
Zend server 6 using zf2, 2013 webinarZend server 6 using zf2, 2013 webinar
Zend server 6 using zf2, 2013 webinarYonni Mendes
 
Automating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiAutomating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiYonni Mendes
 
Tutorial: extending the zend server ui and web api
Tutorial: extending the zend server ui and web apiTutorial: extending the zend server ui and web api
Tutorial: extending the zend server ui and web apiYonni Mendes
 
Zend server 6 compliance
Zend server 6  complianceZend server 6  compliance
Zend server 6 complianceYonni Mendes
 

More from Yonni Mendes (8)

Debriefing and post-mortems
Debriefing and post-mortemsDebriefing and post-mortems
Debriefing and post-mortems
 
Estimations and confidence
Estimations and confidenceEstimations and confidence
Estimations and confidence
 
Agile & What I know about it
Agile & What I know about itAgile & What I know about it
Agile & What I know about it
 
Apigility & Restfull APIs
Apigility & Restfull APIsApigility & Restfull APIs
Apigility & Restfull APIs
 
Zend server 6 using zf2, 2013 webinar
Zend server 6 using zf2, 2013 webinarZend server 6 using zf2, 2013 webinar
Zend server 6 using zf2, 2013 webinar
 
Automating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiAutomating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server api
 
Tutorial: extending the zend server ui and web api
Tutorial: extending the zend server ui and web apiTutorial: extending the zend server ui and web api
Tutorial: extending the zend server ui and web api
 
Zend server 6 compliance
Zend server 6  complianceZend server 6  compliance
Zend server 6 compliance
 

Recently uploaded

Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksJinanKordab
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAShane Coughlan
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIInflectra
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Conceptsthomashtkim
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...naitiksharma1124
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanNeo4j
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jNeo4j
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletAndrea Goulet
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringPrakhyath Rai
 
Test Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdfTest Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdfkalichargn70th171
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdftimtebeek1
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdfSelfMade bd
 
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...drm1699
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfkalichargn70th171
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Maxim Salnikov
 
Your Ultimate Web Studio for Streaming Anywhere | Evmux
Your Ultimate Web Studio for Streaming Anywhere | EvmuxYour Ultimate Web Studio for Streaming Anywhere | Evmux
Your Ultimate Web Studio for Streaming Anywhere | Evmuxevmux96
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConNatan Silnitsky
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMarkus Moeller
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationElement34
 

Recently uploaded (20)

Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST API
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Concepts
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 
Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...
Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...
Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements Engineering
 
Test Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdfTest Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdf
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
 
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?
 
Your Ultimate Web Studio for Streaming Anywhere | Evmux
Your Ultimate Web Studio for Streaming Anywhere | EvmuxYour Ultimate Web Studio for Streaming Anywhere | Evmux
Your Ultimate Web Studio for Streaming Anywhere | Evmux
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 

When to refactor

  • 1. When to refactor And when to stop
  • 2. Good, clean code is ready for change. If the code is good enough to change, there’s probably no refactor needed
  • 3. Refactoring is the practice of breaking up code or logic in preparation for change. Refactor before you make a change to the code: ● Add tests to make concrete the logic ● Simplify or clarify the logic ● Uniform the business language ● Change the data model so it easy to modify Refactoring after a change is made is Clean up. Why Refactoring
  • 4. What is not refactoring Refactoring is not "gardening", or "grooming". Refactoring is not cleanup Refactor is not a rewrite Refactoring keeps the existing process in place and keeps existing contracts. Grooming the code for solving a more generalised problem may drive us to make incorrect choices for the future
  • 5. Refactoring steps 1. Add tests to make concrete the current logic, make the code testable enough 2. Run the tests: green result 3. Refactor the code 4. Rerun the tests: correct till green result 5. Repeat till code is simple “enough” 6. Ready to make logic changes
  • 6. I can stop whenever I want! Stop refactoring when the logical unit is "small enough". Small enough? To easily reuse? To easily test? To easily change? To easily extend? Refactoring steps have upper and lower limits, usually in the current logic unit. Do not "go deep". Refactor only the immediate unit so that the change is small enough to easily test

Editor's Notes

  1. Sometimes the "refactoring" is just adding tests or renaming to business language. Other times it is a data model change or the extraction of logic to make the problem space "smaller". Sometimes we refactor before we "get to work", sometimes it is broken down into cycles of refactor-test-change
  2. Cleanup: done after the change was made Rewrites solve architectural issues or approach the problem in a completely new way