SlideShare una empresa de Scribd logo
1 de 18
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.

Más contenido relacionado

Destacado (7)

Chc ja-m &e officer-12.12.2014
Chc ja-m &e officer-12.12.2014Chc ja-m &e officer-12.12.2014
Chc ja-m &e officer-12.12.2014
 
Job annocement field supervisor v-1
Job annocement field supervisor v-1Job annocement field supervisor v-1
Job annocement field supervisor v-1
 
Felipe glez
Felipe glezFelipe glez
Felipe glez
 
Chc ja pc shp_tmor puk_02022015
Chc ja pc shp_tmor puk_02022015Chc ja pc shp_tmor puk_02022015
Chc ja pc shp_tmor puk_02022015
 
Politicas Educativas
Politicas EducativasPoliticas Educativas
Politicas Educativas
 
Tema 12 los gobiernos democráticos
Tema 12   los gobiernos democráticosTema 12   los gobiernos democráticos
Tema 12 los gobiernos democráticos
 
Definiciones de política educativa
Definiciones de política educativaDefiniciones de política educativa
Definiciones de política educativa
 

Similar a Principlesinrefactoring 090906230021-phpapp01

Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in Refactoring
Chamnap Chhorn
 
Reengineering including reverse & forward Engineering
Reengineering including reverse & forward EngineeringReengineering including reverse & forward Engineering
Reengineering including reverse & forward Engineering
Muhammad Chaudhry
 
CSCI-383 Lecture 5-6-7: Object-Oriented Design
CSCI-383 Lecture 5-6-7: Object-Oriented DesignCSCI-383 Lecture 5-6-7: Object-Oriented Design
CSCI-383 Lecture 5-6-7: Object-Oriented Design
JI Ruan
 

Similar a Principlesinrefactoring 090906230021-phpapp01 (20)

Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in Refactoring
 
Software design.edited (1)
Software design.edited (1)Software design.edited (1)
Software design.edited (1)
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and Patterns
 
Refactoring 2 The Max
Refactoring 2 The MaxRefactoring 2 The Max
Refactoring 2 The Max
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship Checklist
 
Mit104 software engineering
Mit104  software engineeringMit104  software engineering
Mit104 software engineering
 
Lecture1422914635
Lecture1422914635Lecture1422914635
Lecture1422914635
 
Mastering Data Engineering: Common Data Engineer Interview Questions You Shou...
Mastering Data Engineering: Common Data Engineer Interview Questions You Shou...Mastering Data Engineering: Common Data Engineer Interview Questions You Shou...
Mastering Data Engineering: Common Data Engineer Interview Questions You Shou...
 
Software re engineering
Software re engineeringSoftware re engineering
Software re engineering
 
Advanced Software Engineering.ppt
Advanced Software Engineering.pptAdvanced Software Engineering.ppt
Advanced Software Engineering.ppt
 
Grokking Simplicity: taking a new approach to programming
Grokking Simplicity: taking a new approach to programmingGrokking Simplicity: taking a new approach to programming
Grokking Simplicity: taking a new approach to programming
 
The dependency inversion principle
The dependency inversion principleThe dependency inversion principle
The dependency inversion principle
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure
 
Reengineering including reverse & forward Engineering
Reengineering including reverse & forward EngineeringReengineering including reverse & forward Engineering
Reengineering including reverse & forward Engineering
 
Thoughtful Software Design
Thoughtful Software DesignThoughtful Software Design
Thoughtful Software Design
 
Software Engineering Book for beginnerss
Software Engineering Book for beginnerssSoftware Engineering Book for beginnerss
Software Engineering Book for beginnerss
 
Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development
 
Software engineering introduction
Software engineering introductionSoftware engineering introduction
Software engineering introduction
 
Refactoring PHP
Refactoring PHPRefactoring PHP
Refactoring PHP
 
CSCI-383 Lecture 5-6-7: Object-Oriented Design
CSCI-383 Lecture 5-6-7: Object-Oriented DesignCSCI-383 Lecture 5-6-7: Object-Oriented Design
CSCI-383 Lecture 5-6-7: Object-Oriented Design
 

Más de Sopheak Sem

Chc ja-mdr-tb nurses.12.12.2014
Chc ja-mdr-tb nurses.12.12.2014Chc ja-mdr-tb nurses.12.12.2014
Chc ja-mdr-tb nurses.12.12.2014
Sopheak Sem
 
Announcement on advaced tot bcc
Announcement on advaced tot bccAnnouncement on advaced tot bcc
Announcement on advaced tot bcc
Sopheak Sem
 
Application form advanced tot bcc
Application form advanced tot bccApplication form advanced tot bcc
Application form advanced tot bcc
Sopheak Sem
 
Outline of sales promotion workshop v 1 2_12aug14
Outline of sales promotion workshop v 1 2_12aug14Outline of sales promotion workshop v 1 2_12aug14
Outline of sales promotion workshop v 1 2_12aug14
Sopheak Sem
 
Analysis of-gender-and-emerging-issues-with-focus-on-ageing-population-help a...
Analysis of-gender-and-emerging-issues-with-focus-on-ageing-population-help a...Analysis of-gender-and-emerging-issues-with-focus-on-ageing-population-help a...
Analysis of-gender-and-emerging-issues-with-focus-on-ageing-population-help a...
Sopheak Sem
 
Ageing&migrationin cambodia26dec2013 (1)
Ageing&migrationin cambodia26dec2013 (1)Ageing&migrationin cambodia26dec2013 (1)
Ageing&migrationin cambodia26dec2013 (1)
Sopheak Sem
 
Cambodia's older people's association guidelines (1)
Cambodia's older people's association guidelines (1)Cambodia's older people's association guidelines (1)
Cambodia's older people's association guidelines (1)
Sopheak Sem
 
Support for the elderly in cambodia letter
Support for the elderly in cambodia letterSupport for the elderly in cambodia letter
Support for the elderly in cambodia letter
Sopheak Sem
 
Isps course announcement 2014 15_giz
Isps course announcement 2014 15_gizIsps course announcement 2014 15_giz
Isps course announcement 2014 15_giz
Sopheak Sem
 
To r lgcr 14-007
To r lgcr 14-007To r lgcr 14-007
To r lgcr 14-007
Sopheak Sem
 
Application form of chpm
Application form of chpmApplication form of chpm
Application form of chpm
Sopheak Sem
 
Announcement on chpm
Announcement on chpmAnnouncement on chpm
Announcement on chpm
Sopheak Sem
 
Concept note heifer
Concept note heiferConcept note heifer
Concept note heifer
Sopheak Sem
 
Case study 1 06 sept 13
Case study 1 06 sept 13Case study 1 06 sept 13
Case study 1 06 sept 13
Sopheak Sem
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02
Sopheak Sem
 
Espositoajaxremote 1210732828647866-8
Espositoajaxremote 1210732828647866-8Espositoajaxremote 1210732828647866-8
Espositoajaxremote 1210732828647866-8
Sopheak Sem
 
Introductiontorails 120804023905-phpapp02
Introductiontorails 120804023905-phpapp02Introductiontorails 120804023905-phpapp02
Introductiontorails 120804023905-phpapp02
Sopheak Sem
 

Más de Sopheak Sem (20)

Chc ja-mdr-tb nurses.12.12.2014
Chc ja-mdr-tb nurses.12.12.2014Chc ja-mdr-tb nurses.12.12.2014
Chc ja-mdr-tb nurses.12.12.2014
 
Outline of consultative workshop on integrated promotion v.1.1 14_oct2014
Outline of consultative workshop on integrated promotion v.1.1 14_oct2014Outline of consultative workshop on integrated promotion v.1.1 14_oct2014
Outline of consultative workshop on integrated promotion v.1.1 14_oct2014
 
Announcement on advaced tot bcc
Announcement on advaced tot bccAnnouncement on advaced tot bcc
Announcement on advaced tot bcc
 
Application form advanced tot bcc
Application form advanced tot bccApplication form advanced tot bcc
Application form advanced tot bcc
 
Outline of sales promotion workshop v 1 2_12aug14
Outline of sales promotion workshop v 1 2_12aug14Outline of sales promotion workshop v 1 2_12aug14
Outline of sales promotion workshop v 1 2_12aug14
 
Analysis of-gender-and-emerging-issues-with-focus-on-ageing-population-help a...
Analysis of-gender-and-emerging-issues-with-focus-on-ageing-population-help a...Analysis of-gender-and-emerging-issues-with-focus-on-ageing-population-help a...
Analysis of-gender-and-emerging-issues-with-focus-on-ageing-population-help a...
 
Ageing&migrationin cambodia26dec2013 (1)
Ageing&migrationin cambodia26dec2013 (1)Ageing&migrationin cambodia26dec2013 (1)
Ageing&migrationin cambodia26dec2013 (1)
 
Cambodia's older people's association guidelines (1)
Cambodia's older people's association guidelines (1)Cambodia's older people's association guidelines (1)
Cambodia's older people's association guidelines (1)
 
Support for the elderly in cambodia letter
Support for the elderly in cambodia letterSupport for the elderly in cambodia letter
Support for the elderly in cambodia letter
 
Isps course announcement 2014 15_giz
Isps course announcement 2014 15_gizIsps course announcement 2014 15_giz
Isps course announcement 2014 15_giz
 
To r lgcr 14-007
To r lgcr 14-007To r lgcr 14-007
To r lgcr 14-007
 
Application form of chpm
Application form of chpmApplication form of chpm
Application form of chpm
 
Announcement on chpm
Announcement on chpmAnnouncement on chpm
Announcement on chpm
 
Bfh
BfhBfh
Bfh
 
Afh
AfhAfh
Afh
 
Concept note heifer
Concept note heiferConcept note heifer
Concept note heifer
 
Case study 1 06 sept 13
Case study 1 06 sept 13Case study 1 06 sept 13
Case study 1 06 sept 13
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02
 
Espositoajaxremote 1210732828647866-8
Espositoajaxremote 1210732828647866-8Espositoajaxremote 1210732828647866-8
Espositoajaxremote 1210732828647866-8
 
Introductiontorails 120804023905-phpapp02
Introductiontorails 120804023905-phpapp02Introductiontorails 120804023905-phpapp02
Introductiontorails 120804023905-phpapp02
 

Último

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

Último (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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
 
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...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
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 ...
 
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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Principlesinrefactoring 090906230021-phpapp01

  • 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.