SlideShare a Scribd company logo
 
Defining Refactoring The word  Refactoring  has two definitions depending on context. Refactoring  (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior. Refactor  (verb): to restructure software by applying a series of refactorings without changing its observable behavior.
Defining Refactoring The purpose of refactoring is to make the software easier to understand and modify. It only alters the internal structure. A good contrast is performance optimization. Refactoring does not change the observable behavior of the software.
The Two Hats Two distinct activities: adding function and refactoring. When you add function, you shouldn't be changing existing code; you are just adding new capabilities. When you refactor, you make a point of not adding function; you only restructure the code.
 
Refactoring Improves the Design of Software Without refactoring, the design of the program will decay. Poorly designed code usually takes more code to do the same things.
Refactoring Makes Software Easier to Understand Programming is in many ways a conversation with a computer. There is another user of your source code. “ I use refactoring to help me understand unfamiliar code. I actually change the code to better reflect my understanding.”
Refactoring Helps You Find Bugs Help in understanding the code also helps me spot bugs. "I'm not a great programmer; I'm just a good programmer with great habits."
Refactoring Helps You Program Faster Refactoring helps you develop software more rapidly, because it stops the design of the system from decaying.
When Should You Refactor? Refactor When You Add Function Refactor When You Need to Fix a Bug Refactor As You Do a Code Review
What Do I Tell My Manager? If the manager is technically savvy, introducing the subject may not be that hard. If the manager is  genuinely  quality oriented, then the thing to stress is the quality aspects. Of course, many people say they are driven by quality but are more driven by schedule. In these cases I give my more controversial advice: Don't tell!
 
Databases Most business applications are tightly coupled to the database schema that supports them. The database is difficult to change. Another reason is data migration. With nonobject databases, place a separate layer of software between your object model and your database model. Object databases both help and hinder.
Changing Interfaces There is no problem changing a method name if you have access to all the code that calls that method. There is a problem only if the interface is being used by code that you cannot find and change. Don't publish interfaces prematurely. Modify your code ownership policies to smooth refactoring.
Design Changes That Are Difficult to Refactor How difficult would it be to refactor from one design into another? Pick the simplest design if it seems easy. Otherwise put more effort into the design.
Refactoring and Design Refactoring can be an alternative to upfront design. In refactoring, you still do upfront design, but now you don't try to find the solution. Instead all you want is a reasonable solution. You know that as you build the solution, as you understand more about the problem An important result of this change in emphasis is a greater movement toward simplicity of design.
Refactoring and Performance A common concern with refactoring is the effect it has on the performance of a program. Three general approaches to writing fast software: time/footprint budget for resources constant attention approach performance improvement
Where Did Refactoring Come From? Two of the first people to recognize the importance of refactoring were Ward Cunningham and Kent Beck, who worked with Smalltalk from the 1980s onward.

More Related Content

What's hot (20)

PPS
Few minutes To better Code - Refactoring
Diaa Al-Salehi
 
PDF
Big code refactoring with agility
Luca Merolla
 
PPTX
Refactoring Applications using SOLID Principles
Steven Smith
 
PPT
TDD And Refactoring
Naresh Jain
 
PPTX
Refactoring legacy code driven by tests - ENG
Luca Minudel
 
PDF
Unit testing legacy code
Lars Thorup
 
PDF
Adding Unit Test To Legacy Code
Terry Yin
 
PPTX
scope of python
Dwarak Besant
 
ODP
Refactoring Techniques
Mayada Ghanem
 
PPTX
Web tech: lecture 5
Ardak Shalkarbayuli
 
PPTX
C# coding standards, good programming principles & refactoring
Eyob Lube
 
PDF
Bad Code Smells
kim.mens
 
PDF
Refactoring
Herez Moise Kattan
 
PPTX
SAD10 - Refactoring
Michael Heron
 
ODP
Tdd in php a brief example
Jeremy Kendall
 
PPTX
L2624 labriola
michael.labriola
 
PPTX
django
Mohamed Essam
 
PPTX
The "Evils" of Optimization
BlackRabbitCoder
 
PDF
Legacy Coderetreat @Budapest 2013 02 16
Adi Bolboaca
 
PPTX
2CPP12 - Method Overriding
Michael Heron
 
Few minutes To better Code - Refactoring
Diaa Al-Salehi
 
Big code refactoring with agility
Luca Merolla
 
Refactoring Applications using SOLID Principles
Steven Smith
 
TDD And Refactoring
Naresh Jain
 
Refactoring legacy code driven by tests - ENG
Luca Minudel
 
Unit testing legacy code
Lars Thorup
 
Adding Unit Test To Legacy Code
Terry Yin
 
scope of python
Dwarak Besant
 
Refactoring Techniques
Mayada Ghanem
 
Web tech: lecture 5
Ardak Shalkarbayuli
 
C# coding standards, good programming principles & refactoring
Eyob Lube
 
Bad Code Smells
kim.mens
 
Refactoring
Herez Moise Kattan
 
SAD10 - Refactoring
Michael Heron
 
Tdd in php a brief example
Jeremy Kendall
 
L2624 labriola
michael.labriola
 
The "Evils" of Optimization
BlackRabbitCoder
 
Legacy Coderetreat @Budapest 2013 02 16
Adi Bolboaca
 
2CPP12 - Method Overriding
Michael Heron
 

Viewers also liked (6)

PPTX
Ben Reich - Continuous Integration Best Practices in Agile Environments
AgileSparks
 
PDF
Refactoring for Design Smells - ICSE 2014 Tutorial
Tushar Sharma
 
PDF
Introduction to rails
Chamnap Chhorn
 
PDF
Unsupervised Machine Learning for clone detection
Valerio Maggio
 
PDF
Refactoring for Software Design Smells: Managing Technical Debt
Tushar Sharma
 
PDF
Design patterns
abhisheksagi
 
Ben Reich - Continuous Integration Best Practices in Agile Environments
AgileSparks
 
Refactoring for Design Smells - ICSE 2014 Tutorial
Tushar Sharma
 
Introduction to rails
Chamnap Chhorn
 
Unsupervised Machine Learning for clone detection
Valerio Maggio
 
Refactoring for Software Design Smells: Managing Technical Debt
Tushar Sharma
 
Design patterns
abhisheksagi
 
Ad

Similar to Principles in Refactoring (20)

PPT
Principlesinrefactoring 090906230021-phpapp01
Sopheak Sem
 
PPTX
Refactoring
Rabeya Bashri
 
PDF
The Power Of Refactoring (4developers Krakow)
Stefan Koopmanschap
 
PDF
The Power Of Refactoring (php|tek 09)
Stefan Koopmanschap
 
PDF
Code Refactoring in Software Development
philipthomas428223
 
PDF
The Power Of Refactoring (PHPCon Italia)
Stefan Koopmanschap
 
PDF
Refactoring, Therapeutic Attitude to Programming.
Amin Shahnazari
 
PPTX
Code refactoring
Lalit Kale
 
PDF
Refactoring 2TheMax (con ReSharper)
DotNetMarche
 
PDF
Lecture28
liufabin 66688
 
PDF
Refactoring 2 The Max
Alfredo Morresi
 
ODP
Refactoring: Improving the design of existing code
Knoldus Inc.
 
PPT
Refactoring, A First Example
Vorleak Chy
 
PPTX
Refactoring, 2nd Edition
jexp
 
PPTX
Refactoring
AngelLuisBlasco
 
PDF
Code refactoring
Long Nguyen
 
PPTX
Everything you Wanted to Know About Refactoring
Gary Short
 
PPTX
When to refactor
Yonni Mendes
 
PDF
Refactoring PHP
Adam Culp
 
PPTX
Agile Australia 2016 - Rescuing Legacy Software from Impending Doom
Jacques De Vos
 
Principlesinrefactoring 090906230021-phpapp01
Sopheak Sem
 
Refactoring
Rabeya Bashri
 
The Power Of Refactoring (4developers Krakow)
Stefan Koopmanschap
 
The Power Of Refactoring (php|tek 09)
Stefan Koopmanschap
 
Code Refactoring in Software Development
philipthomas428223
 
The Power Of Refactoring (PHPCon Italia)
Stefan Koopmanschap
 
Refactoring, Therapeutic Attitude to Programming.
Amin Shahnazari
 
Code refactoring
Lalit Kale
 
Refactoring 2TheMax (con ReSharper)
DotNetMarche
 
Lecture28
liufabin 66688
 
Refactoring 2 The Max
Alfredo Morresi
 
Refactoring: Improving the design of existing code
Knoldus Inc.
 
Refactoring, A First Example
Vorleak Chy
 
Refactoring, 2nd Edition
jexp
 
Refactoring
AngelLuisBlasco
 
Code refactoring
Long Nguyen
 
Everything you Wanted to Know About Refactoring
Gary Short
 
When to refactor
Yonni Mendes
 
Refactoring PHP
Adam Culp
 
Agile Australia 2016 - Rescuing Legacy Software from Impending Doom
Jacques De Vos
 
Ad

More from Chamnap Chhorn (6)

PDF
High performance website
Chamnap Chhorn
 
PPTX
Ruby object model
Chamnap Chhorn
 
PPTX
Rest and Rails
Chamnap Chhorn
 
PPTX
Introduction to Web Architecture
Chamnap Chhorn
 
PPTX
JavaScript in Object-Oriented Way
Chamnap Chhorn
 
PPT
Rest in Rails
Chamnap Chhorn
 
High performance website
Chamnap Chhorn
 
Ruby object model
Chamnap Chhorn
 
Rest and Rails
Chamnap Chhorn
 
Introduction to Web Architecture
Chamnap Chhorn
 
JavaScript in Object-Oriented Way
Chamnap Chhorn
 
Rest in Rails
Chamnap Chhorn
 

Recently uploaded (20)

PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 

Principles in Refactoring

  • 1.  
  • 2. Defining Refactoring The word Refactoring has two definitions depending on context. Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior. Refactor (verb): to restructure software by applying a series of refactorings without changing its observable behavior.
  • 3. Defining Refactoring The purpose of refactoring is to make the software easier to understand and modify. It only alters the internal structure. A good contrast is performance optimization. Refactoring does not change the observable behavior of the software.
  • 4. The Two Hats Two distinct activities: adding function and refactoring. When you add function, you shouldn't be changing existing code; you are just adding new capabilities. When you refactor, you make a point of not adding function; you only restructure the code.
  • 5.  
  • 6. Refactoring Improves the Design of Software Without refactoring, the design of the program will decay. Poorly designed code usually takes more code to do the same things.
  • 7. Refactoring Makes Software Easier to Understand Programming is in many ways a conversation with a computer. There is another user of your source code. “ I use refactoring to help me understand unfamiliar code. I actually change the code to better reflect my understanding.”
  • 8. Refactoring Helps You Find Bugs Help in understanding the code also helps me spot bugs. "I'm not a great programmer; I'm just a good programmer with great habits."
  • 9. Refactoring Helps You Program Faster Refactoring helps you develop software more rapidly, because it stops the design of the system from decaying.
  • 10. When Should You Refactor? Refactor When You Add Function Refactor When You Need to Fix a Bug Refactor As You Do a Code Review
  • 11. What Do I Tell My Manager? If the manager is technically savvy, introducing the subject may not be that hard. If the manager is genuinely quality oriented, then the thing to stress is the quality aspects. Of course, many people say they are driven by quality but are more driven by schedule. In these cases I give my more controversial advice: Don't tell!
  • 12.  
  • 13. Databases Most business applications are tightly coupled to the database schema that supports them. The database is difficult to change. Another reason is data migration. With nonobject databases, place a separate layer of software between your object model and your database model. Object databases both help and hinder.
  • 14. Changing Interfaces There is no problem changing a method name if you have access to all the code that calls that method. There is a problem only if the interface is being used by code that you cannot find and change. Don't publish interfaces prematurely. Modify your code ownership policies to smooth refactoring.
  • 15. Design Changes That Are Difficult to Refactor How difficult would it be to refactor from one design into another? Pick the simplest design if it seems easy. Otherwise put more effort into the design.
  • 16. Refactoring and Design Refactoring can be an alternative to upfront design. In refactoring, you still do upfront design, but now you don't try to find the solution. Instead all you want is a reasonable solution. You know that as you build the solution, as you understand more about the problem An important result of this change in emphasis is a greater movement toward simplicity of design.
  • 17. Refactoring and Performance A common concern with refactoring is the effect it has on the performance of a program. Three general approaches to writing fast software: time/footprint budget for resources constant attention approach performance improvement
  • 18. Where Did Refactoring Come From? Two of the first people to recognize the importance of refactoring were Ward Cunningham and Kent Beck, who worked with Smalltalk from the 1980s onward.