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

Weitere ähnliche Inhalte

Andere mochten auch (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
 

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

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

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

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

Kürzlich hochgeladen

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

Kürzlich hochgeladen (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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...
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+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...
 
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...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

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.