SlideShare une entreprise Scribd logo
1  sur  40
The Power of Refactoring




                Stefan Koopmanschap
     PHP|tek, Chicago, May 22nd 2009
What will we do?

 What is refactoring?
 Why refactoring?
 When refactoring?
 Requirements
 HOWTO




                        2
Stefan Koopmanschap
Who is he?




                      3
About me

 Professional Services Consultant at Ibuildings
 10 years of PHP experience
 PHP auto didact
 married, 2 kids, 6 cats, a bunch of fish
 Apple lover
 music addict
 symfony advocate




                                                  4
Refactoring
What is it?




              5
Refactoring is a disciplined technique for restructuring
an existing body of code, altering its internal structure
without changing its external behavior. Its heart is a
series of small behavior preserving transformations.
Each transformation (called a 'refactoring') does little,
but a sequence of transformations can produce a
significant restructuring. Since each refactoring is small,
it's less likely to go wrong. The system is also kept fully
working after each small refactoring, reducing the
chances that a system can get seriously broken during
the restructuring.
(Martin Fowler - Refactoring.com)



                                                              6
Code refactoring is the process of changing a computer
program's code to make it amenable to change,
improve its readability, or simplify its structure, while
preserving its existing functionality.
(Wikipedia)




                                                            7
What

Code refactoring is the process of changing a computer
program's internal structure without modifying its
external behavior or existing functionality.




                                                         8
Why

This is usually done to improve code readability, simplify
code structure, change code to adhere to a given
programming paradigm, improve maintainability, or
improve extensibility.




                                                             9
Improve readability




                      10
Improve maintainability




                          11
Extend (or change)




                     12
Is it the holy grail?




                        13
Rewrite

A rewrite in computer programming is the act or result of
re-implementing a large portion of existing functionality
without re-use of its source code. When the rewrite is not
using existing code at all, it is common to speak of a
rewrite from scratch. When instead only parts are re-
engineered, which have otherwise become complicated to
handle or extend, then it is more precise to speak of code
refactoring.
(Wikipedia)




                                                         14
Refactor vs Rewrite

 Refactor whenever it is possible
 Big change? Try to cut it into smaller units
 Still have to break the API? Go ahead, and rewrite!
 Don’t take the decision in 5 minutes




                                                       15
Refactor vs Rewrite

Refactoring takes less effort
  Nice for you
  Better for the quality of your work
Breaking the API is more work
  Ensure all calling code is altered as well
  Update your unit tests
  Update your documentation




                                               16
Requirements
for successful refactoring




                             17
Requirements

 Codebase knowledge
 Structured API
 Unit testing




                      18
Codebase knowledge

 Know what to change quickly
 Be aware of your changes
 Be aware of impact of your changes on other components




                                                          19
Structured API

 Refactoring DOES NOT REPLACE design!
 You need a good API that allows internal changes
 Additions to existing API’s should not change existing API
 Keep small “units”




                                                              20
Unit testing

 Unit testing is your first point of QA
 They safeguard you from unexpected side effects
 Test - Change - Test




                                                   21
When?
Timing of refactoring




                        22
Two moments of refactoring

 Big chunks
 Continuous refactoring




                             23
Big Chunks

 As you encounter problems, you keep track
 • Ticketing system
 • TODO list
 • Inline comments
 Schedule one or more moments in your project
 • Work through your list
 • Refactor them




                                                24
Big Chunks work?

 Advantages
 • Set times for refactoring
 • Focus on your project when you need to
 • Works well for functional changes
 Disadvantages
 • Refactoring gets cancelled first with tight deadlines
 • You may have forgotten specific solutions already




                                                           25
Continuous Refactoring

 Refactor while you work
 Encounter a problem, fix it!




                                26
Continuous Refactoring works?

 Advantages
 • No need to schedule seperate time
 • Continuous improvement of your code
 Disadvantages
 • Danger of losing the balance between tasks and refactoring




                                                                27
Who should refactor?




                       28
Who should refactor?

 Someone with knowledge of the codebase
 • Or at least the part that is being refactored
 Not necessarily the code owner




                                                   29
An example
user authentication




                      30
A test-driven approach




                         31
My first implementation




                          32
A more dynamic version




                         33
Tips and tricks




                  34
Some tips and tricks

 Write unit tests before you start refactoring
 Code documentation (phpDoc) is your friend
 Don’t trust your IDE’s refactoring options




                                                 35
Looking back

 What is refactoring?
 Why do we want to refactor?
 Is it the holy grail?
 Refactoring vs Rewriting
 Requirements
 How to do it
 Tips and tricks




                               36
The Power of Refactoring




                           37
Creative Commons Rocks!
Readability:
http://www.flickr.com/photos/vipulmathur/
471634239/ (by-nc-sa/2.0)
Maintainability:
http://www.flickr.com/photos/sveinhal/
2416609728/ (by-nc-nd/2.0)
Extend:
http://www.flickr.com/photos/
30691679@N07/2972145815/ (by-nc-sa/2.0)
Holy Grail:
http://www.flickr.com/photos/joebeone/
153921142/ (by/2.0)




                                            38
Questions ?




              39
Thank you!
                Contact details:
           Stefan Koopmanschap
  http://www.leftontheweb.com/
      http://www.ibuildings.com/
   http://www.twitter.com/skoop
http://www.slideshare.net/skoop
    http://joind.in/talk/view/240

Contenu connexe

Tendances

Rational Functional Tester
Rational Functional TesterRational Functional Tester
Rational Functional TesterRavi Anand
 
NIWeek 2012: Secret Sauce / Tools to Make You a Better LabVIEW Developer
NIWeek 2012: Secret Sauce / Tools to Make You a Better LabVIEW DeveloperNIWeek 2012: Secret Sauce / Tools to Make You a Better LabVIEW Developer
NIWeek 2012: Secret Sauce / Tools to Make You a Better LabVIEW DeveloperJKI
 
Shirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-asShirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-asAgileSparks
 
TMF2014 CI-CD Workshop Michael Palotas
TMF2014 CI-CD Workshop Michael PalotasTMF2014 CI-CD Workshop Michael Palotas
TMF2014 CI-CD Workshop Michael PalotasKJR
 
Pivotal Labs Open View Presentation Continuous Build
Pivotal Labs Open View Presentation Continuous BuildPivotal Labs Open View Presentation Continuous Build
Pivotal Labs Open View Presentation Continuous Buildguestc8adce
 
Continuous delivery @åf consult
Continuous delivery @åf consultContinuous delivery @åf consult
Continuous delivery @åf consultTomas Riha
 
Pivotal Labs Open View Presentation Quality Assurance And Developer Testing
Pivotal Labs Open View Presentation Quality Assurance And Developer TestingPivotal Labs Open View Presentation Quality Assurance And Developer Testing
Pivotal Labs Open View Presentation Quality Assurance And Developer Testingguestc8adce
 
Code Refactoring
Code RefactoringCode Refactoring
Code RefactoringYu-Chih Lin
 
Антон Семенченко | (EPAM Systems, DPI.Solutions )Сравнительный анализ инстру...
Антон Семенченко | (EPAM Systems, DPI.Solutions )Сравнительный анализ инстру...Антон Семенченко | (EPAM Systems, DPI.Solutions )Сравнительный анализ инстру...
Антон Семенченко | (EPAM Systems, DPI.Solutions )Сравнительный анализ инстру...RIF-Technology
 
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex Environments
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex EnvironmentsDr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex Environments
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex EnvironmentsAgileSparks
 
Shirly Ronen - Documenting an agile defect
Shirly Ronen - Documenting an agile defectShirly Ronen - Documenting an agile defect
Shirly Ronen - Documenting an agile defectAgileSparks
 
Git workflow step by step
Git workflow step by stepGit workflow step by step
Git workflow step by stepBinh Quan Duc
 
Shirly Ronen - User story testing activities
Shirly Ronen - User story testing activitiesShirly Ronen - User story testing activities
Shirly Ronen - User story testing activitiesAgileSparks
 
Extreme Programming
Extreme ProgrammingExtreme Programming
Extreme ProgrammingKnoldus Inc.
 
CLA Summit 2013: Connecting LabVIEW to Everything Else
CLA Summit 2013: Connecting LabVIEW to Everything ElseCLA Summit 2013: Connecting LabVIEW to Everything Else
CLA Summit 2013: Connecting LabVIEW to Everything ElseJKI
 
JenkinsCIdocumentations-removedcredentials.docx
JenkinsCIdocumentations-removedcredentials.docxJenkinsCIdocumentations-removedcredentials.docx
JenkinsCIdocumentations-removedcredentials.docxMd. Abdul Hasib (Sazzad)
 

Tendances (20)

Rational Functional Tester
Rational Functional TesterRational Functional Tester
Rational Functional Tester
 
NIWeek 2012: Secret Sauce / Tools to Make You a Better LabVIEW Developer
NIWeek 2012: Secret Sauce / Tools to Make You a Better LabVIEW DeveloperNIWeek 2012: Secret Sauce / Tools to Make You a Better LabVIEW Developer
NIWeek 2012: Secret Sauce / Tools to Make You a Better LabVIEW Developer
 
Agileee 2012
Agileee 2012Agileee 2012
Agileee 2012
 
Shirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-asShirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-as
 
Test Strategy
Test StrategyTest Strategy
Test Strategy
 
TMF2014 CI-CD Workshop Michael Palotas
TMF2014 CI-CD Workshop Michael PalotasTMF2014 CI-CD Workshop Michael Palotas
TMF2014 CI-CD Workshop Michael Palotas
 
Check in dance
Check in danceCheck in dance
Check in dance
 
Pivotal Labs Open View Presentation Continuous Build
Pivotal Labs Open View Presentation Continuous BuildPivotal Labs Open View Presentation Continuous Build
Pivotal Labs Open View Presentation Continuous Build
 
Continuous delivery @åf consult
Continuous delivery @åf consultContinuous delivery @åf consult
Continuous delivery @åf consult
 
Pivotal Labs Open View Presentation Quality Assurance And Developer Testing
Pivotal Labs Open View Presentation Quality Assurance And Developer TestingPivotal Labs Open View Presentation Quality Assurance And Developer Testing
Pivotal Labs Open View Presentation Quality Assurance And Developer Testing
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Антон Семенченко | (EPAM Systems, DPI.Solutions )Сравнительный анализ инстру...
Антон Семенченко | (EPAM Systems, DPI.Solutions )Сравнительный анализ инстру...Антон Семенченко | (EPAM Systems, DPI.Solutions )Сравнительный анализ инстру...
Антон Семенченко | (EPAM Systems, DPI.Solutions )Сравнительный анализ инстру...
 
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex Environments
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex EnvironmentsDr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex Environments
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex Environments
 
Shirly Ronen - Documenting an agile defect
Shirly Ronen - Documenting an agile defectShirly Ronen - Documenting an agile defect
Shirly Ronen - Documenting an agile defect
 
Scrum with VS2010
Scrum with VS2010  Scrum with VS2010
Scrum with VS2010
 
Git workflow step by step
Git workflow step by stepGit workflow step by step
Git workflow step by step
 
Shirly Ronen - User story testing activities
Shirly Ronen - User story testing activitiesShirly Ronen - User story testing activities
Shirly Ronen - User story testing activities
 
Extreme Programming
Extreme ProgrammingExtreme Programming
Extreme Programming
 
CLA Summit 2013: Connecting LabVIEW to Everything Else
CLA Summit 2013: Connecting LabVIEW to Everything ElseCLA Summit 2013: Connecting LabVIEW to Everything Else
CLA Summit 2013: Connecting LabVIEW to Everything Else
 
JenkinsCIdocumentations-removedcredentials.docx
JenkinsCIdocumentations-removedcredentials.docxJenkinsCIdocumentations-removedcredentials.docx
JenkinsCIdocumentations-removedcredentials.docx
 

Similaire à The Power Of Refactoring (php|tek 09)

Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop Itzik Saban
 
Code refactoring
Code refactoringCode refactoring
Code refactoringLalit Kale
 
The Power Of Refactoring (PHPNW)
The Power Of Refactoring (PHPNW)The Power Of Refactoring (PHPNW)
The Power Of Refactoring (PHPNW)Stefan Koopmanschap
 
The View - Lotusscript coding best practices
The View - Lotusscript coding best practicesThe View - Lotusscript coding best practices
The View - Lotusscript coding best practicesBill Buchan
 
Delivery at Scale
Delivery at ScaleDelivery at Scale
Delivery at ScaleAgilar
 
Continuous delivery @wcap 5-09-2013
Continuous delivery   @wcap 5-09-2013Continuous delivery   @wcap 5-09-2013
Continuous delivery @wcap 5-09-2013David Funaro
 
Devnology back toschool software reengineering
Devnology back toschool software reengineeringDevnology back toschool software reengineering
Devnology back toschool software reengineeringDevnology
 
Bots on guard of sdlc
Bots on guard of sdlcBots on guard of sdlc
Bots on guard of sdlcAlexey Tokar
 
The challenges and pitfalls of database deployment automation
The challenges and pitfalls of database deployment automationThe challenges and pitfalls of database deployment automation
The challenges and pitfalls of database deployment automationDBmaestro - Database DevOps
 
Refactoring, Emergent Design & Evolutionary Architecture
Refactoring, Emergent Design & Evolutionary ArchitectureRefactoring, Emergent Design & Evolutionary Architecture
Refactoring, Emergent Design & Evolutionary ArchitectureBrad Appleton
 
Software Quality via Unit Testing
Software Quality via Unit TestingSoftware Quality via Unit Testing
Software Quality via Unit TestingShaun Abram
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware ProgrammingPostSharp Technologies
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy CodeAdam Culp
 
Agile Maintenance
Agile MaintenanceAgile Maintenance
Agile MaintenanceNaresh Jain
 

Similaire à The Power Of Refactoring (php|tek 09) (20)

Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
 
Code refactoring
Code refactoringCode refactoring
Code refactoring
 
The Power of Refactoring
The Power of RefactoringThe Power of Refactoring
The Power of Refactoring
 
The Power Of Refactoring (PHPNW)
The Power Of Refactoring (PHPNW)The Power Of Refactoring (PHPNW)
The Power Of Refactoring (PHPNW)
 
The View - Lotusscript coding best practices
The View - Lotusscript coding best practicesThe View - Lotusscript coding best practices
The View - Lotusscript coding best practices
 
Delivery at Scale
Delivery at ScaleDelivery at Scale
Delivery at Scale
 
Delivery at Scale
Delivery at ScaleDelivery at Scale
Delivery at Scale
 
Refactoring
RefactoringRefactoring
Refactoring
 
Continuous delivery @wcap 5-09-2013
Continuous delivery   @wcap 5-09-2013Continuous delivery   @wcap 5-09-2013
Continuous delivery @wcap 5-09-2013
 
Devnology back toschool software reengineering
Devnology back toschool software reengineeringDevnology back toschool software reengineering
Devnology back toschool software reengineering
 
Bots on guard of sdlc
Bots on guard of sdlcBots on guard of sdlc
Bots on guard of sdlc
 
The challenges and pitfalls of database deployment automation
The challenges and pitfalls of database deployment automationThe challenges and pitfalls of database deployment automation
The challenges and pitfalls of database deployment automation
 
Refactoring, Emergent Design & Evolutionary Architecture
Refactoring, Emergent Design & Evolutionary ArchitectureRefactoring, Emergent Design & Evolutionary Architecture
Refactoring, Emergent Design & Evolutionary Architecture
 
Software Quality via Unit Testing
Software Quality via Unit TestingSoftware Quality via Unit Testing
Software Quality via Unit Testing
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy Code
 
Vue.js Use Cases
Vue.js Use CasesVue.js Use Cases
Vue.js Use Cases
 
Refactoring 2 The Max
Refactoring 2 The MaxRefactoring 2 The Max
Refactoring 2 The Max
 
Agile Maintenance
Agile MaintenanceAgile Maintenance
Agile Maintenance
 
XP O.ppt
XP O.pptXP O.ppt
XP O.ppt
 

Plus de Stefan Koopmanschap

Git for Subversion Users (ZendCon 2011)
Git for Subversion Users (ZendCon 2011)Git for Subversion Users (ZendCon 2011)
Git for Subversion Users (ZendCon 2011)Stefan Koopmanschap
 
A Practical Look at Symfony2 (PHPNW11)
A Practical Look at Symfony2 (PHPNW11)A Practical Look at Symfony2 (PHPNW11)
A Practical Look at Symfony2 (PHPNW11)Stefan Koopmanschap
 
Git For Subversion Users (PHPNW11)
Git For Subversion Users (PHPNW11)Git For Subversion Users (PHPNW11)
Git For Subversion Users (PHPNW11)Stefan Koopmanschap
 
Open Up (International PHP Conference Spring Edition 2011)
Open Up (International PHP Conference Spring Edition 2011)Open Up (International PHP Conference Spring Edition 2011)
Open Up (International PHP Conference Spring Edition 2011)Stefan Koopmanschap
 
Git for Subversion Users (phpDay 2011)
Git for Subversion Users (phpDay 2011)Git for Subversion Users (phpDay 2011)
Git for Subversion Users (phpDay 2011)Stefan Koopmanschap
 
Would you like docs with that? - Zend Webinar
Would you like docs with that? - Zend WebinarWould you like docs with that? - Zend Webinar
Would you like docs with that? - Zend WebinarStefan Koopmanschap
 
Git workshop (2value, 14-12-2010)
Git workshop (2value, 14-12-2010)Git workshop (2value, 14-12-2010)
Git workshop (2value, 14-12-2010)Stefan Koopmanschap
 
Would you like docs with that? (IPC 2010)
Would you like docs with that? (IPC 2010)Would you like docs with that? (IPC 2010)
Would you like docs with that? (IPC 2010)Stefan Koopmanschap
 
Would you like docs with that? (IPC 2010)
Would you like docs with that? (IPC 2010)Would you like docs with that? (IPC 2010)
Would you like docs with that? (IPC 2010)Stefan Koopmanschap
 
Integrating symfony and Zend Framework (IPC 2010)
Integrating symfony and Zend Framework (IPC 2010)Integrating symfony and Zend Framework (IPC 2010)
Integrating symfony and Zend Framework (IPC 2010)Stefan Koopmanschap
 
Would you like docs with that? (Pfcongres 2010)
Would you like docs with that? (Pfcongres 2010)Would you like docs with that? (Pfcongres 2010)
Would you like docs with that? (Pfcongres 2010)Stefan Koopmanschap
 
The Symfony Community - How to (get) help
The Symfony Community - How to (get) helpThe Symfony Community - How to (get) help
The Symfony Community - How to (get) helpStefan Koopmanschap
 
Integrating symfony and Zend Framework (PHPBarcelona 2009)
Integrating symfony and Zend Framework (PHPBarcelona 2009)Integrating symfony and Zend Framework (PHPBarcelona 2009)
Integrating symfony and Zend Framework (PHPBarcelona 2009)Stefan Koopmanschap
 
Integrating symfony and Zend Framework (PHPNW09)
Integrating symfony and Zend Framework (PHPNW09)Integrating symfony and Zend Framework (PHPNW09)
Integrating symfony and Zend Framework (PHPNW09)Stefan Koopmanschap
 
Integrating symfony and Zend Framework
Integrating symfony and Zend FrameworkIntegrating symfony and Zend Framework
Integrating symfony and Zend FrameworkStefan Koopmanschap
 

Plus de Stefan Koopmanschap (20)

A Practical Look At Symfony2
A Practical Look At Symfony2A Practical Look At Symfony2
A Practical Look At Symfony2
 
Git for Subversion Users (ZendCon 2011)
Git for Subversion Users (ZendCon 2011)Git for Subversion Users (ZendCon 2011)
Git for Subversion Users (ZendCon 2011)
 
A Practical Look at Symfony2 (PHPNW11)
A Practical Look at Symfony2 (PHPNW11)A Practical Look at Symfony2 (PHPNW11)
A Practical Look at Symfony2 (PHPNW11)
 
Git For Subversion Users (PHPNW11)
Git For Subversion Users (PHPNW11)Git For Subversion Users (PHPNW11)
Git For Subversion Users (PHPNW11)
 
Conference Speaking 101
Conference Speaking 101Conference Speaking 101
Conference Speaking 101
 
Open Up (International PHP Conference Spring Edition 2011)
Open Up (International PHP Conference Spring Edition 2011)Open Up (International PHP Conference Spring Edition 2011)
Open Up (International PHP Conference Spring Edition 2011)
 
Git for Subversion Users (phpDay 2011)
Git for Subversion Users (phpDay 2011)Git for Subversion Users (phpDay 2011)
Git for Subversion Users (phpDay 2011)
 
Would you like docs with that? - Zend Webinar
Would you like docs with that? - Zend WebinarWould you like docs with that? - Zend Webinar
Would you like docs with that? - Zend Webinar
 
Git workshop (2value, 14-12-2010)
Git workshop (2value, 14-12-2010)Git workshop (2value, 14-12-2010)
Git workshop (2value, 14-12-2010)
 
Git Workshop (Pfz Workshopdag)
Git Workshop (Pfz Workshopdag)Git Workshop (Pfz Workshopdag)
Git Workshop (Pfz Workshopdag)
 
Would you like docs with that? (IPC 2010)
Would you like docs with that? (IPC 2010)Would you like docs with that? (IPC 2010)
Would you like docs with that? (IPC 2010)
 
Would you like docs with that? (IPC 2010)
Would you like docs with that? (IPC 2010)Would you like docs with that? (IPC 2010)
Would you like docs with that? (IPC 2010)
 
Integrating symfony and Zend Framework (IPC 2010)
Integrating symfony and Zend Framework (IPC 2010)Integrating symfony and Zend Framework (IPC 2010)
Integrating symfony and Zend Framework (IPC 2010)
 
symfony 1.4 workshop
symfony 1.4 workshopsymfony 1.4 workshop
symfony 1.4 workshop
 
Would you like docs with that? (Pfcongres 2010)
Would you like docs with that? (Pfcongres 2010)Would you like docs with that? (Pfcongres 2010)
Would you like docs with that? (Pfcongres 2010)
 
The Symfony Community - How to (get) help
The Symfony Community - How to (get) helpThe Symfony Community - How to (get) help
The Symfony Community - How to (get) help
 
Integrating symfony and Zend Framework (PHPBarcelona 2009)
Integrating symfony and Zend Framework (PHPBarcelona 2009)Integrating symfony and Zend Framework (PHPBarcelona 2009)
Integrating symfony and Zend Framework (PHPBarcelona 2009)
 
Integrating symfony and Zend Framework (PHPNW09)
Integrating symfony and Zend Framework (PHPNW09)Integrating symfony and Zend Framework (PHPNW09)
Integrating symfony and Zend Framework (PHPNW09)
 
Integrating symfony and Zend Framework
Integrating symfony and Zend FrameworkIntegrating symfony and Zend Framework
Integrating symfony and Zend Framework
 
Scrum (dutch)
Scrum (dutch)Scrum (dutch)
Scrum (dutch)
 

Dernier

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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 WorkerThousandEyes
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Dernier (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

The Power Of Refactoring (php|tek 09)

  • 1. The Power of Refactoring Stefan Koopmanschap PHP|tek, Chicago, May 22nd 2009
  • 2. What will we do? What is refactoring? Why refactoring? When refactoring? Requirements HOWTO 2
  • 4. About me Professional Services Consultant at Ibuildings 10 years of PHP experience PHP auto didact married, 2 kids, 6 cats, a bunch of fish Apple lover music addict symfony advocate 4
  • 6. Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. Its heart is a series of small behavior preserving transformations. Each transformation (called a 'refactoring') does little, but a sequence of transformations can produce a significant restructuring. Since each refactoring is small, it's less likely to go wrong. The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring. (Martin Fowler - Refactoring.com) 6
  • 7. Code refactoring is the process of changing a computer program's code to make it amenable to change, improve its readability, or simplify its structure, while preserving its existing functionality. (Wikipedia) 7
  • 8. What Code refactoring is the process of changing a computer program's internal structure without modifying its external behavior or existing functionality. 8
  • 9. Why This is usually done to improve code readability, simplify code structure, change code to adhere to a given programming paradigm, improve maintainability, or improve extensibility. 9
  • 13. Is it the holy grail? 13
  • 14. Rewrite A rewrite in computer programming is the act or result of re-implementing a large portion of existing functionality without re-use of its source code. When the rewrite is not using existing code at all, it is common to speak of a rewrite from scratch. When instead only parts are re- engineered, which have otherwise become complicated to handle or extend, then it is more precise to speak of code refactoring. (Wikipedia) 14
  • 15. Refactor vs Rewrite Refactor whenever it is possible Big change? Try to cut it into smaller units Still have to break the API? Go ahead, and rewrite! Don’t take the decision in 5 minutes 15
  • 16. Refactor vs Rewrite Refactoring takes less effort Nice for you Better for the quality of your work Breaking the API is more work Ensure all calling code is altered as well Update your unit tests Update your documentation 16
  • 18. Requirements Codebase knowledge Structured API Unit testing 18
  • 19. Codebase knowledge Know what to change quickly Be aware of your changes Be aware of impact of your changes on other components 19
  • 20. Structured API Refactoring DOES NOT REPLACE design! You need a good API that allows internal changes Additions to existing API’s should not change existing API Keep small “units” 20
  • 21. Unit testing Unit testing is your first point of QA They safeguard you from unexpected side effects Test - Change - Test 21
  • 23. Two moments of refactoring Big chunks Continuous refactoring 23
  • 24. Big Chunks As you encounter problems, you keep track • Ticketing system • TODO list • Inline comments Schedule one or more moments in your project • Work through your list • Refactor them 24
  • 25. Big Chunks work? Advantages • Set times for refactoring • Focus on your project when you need to • Works well for functional changes Disadvantages • Refactoring gets cancelled first with tight deadlines • You may have forgotten specific solutions already 25
  • 26. Continuous Refactoring Refactor while you work Encounter a problem, fix it! 26
  • 27. Continuous Refactoring works? Advantages • No need to schedule seperate time • Continuous improvement of your code Disadvantages • Danger of losing the balance between tasks and refactoring 27
  • 29. Who should refactor? Someone with knowledge of the codebase • Or at least the part that is being refactored Not necessarily the code owner 29
  • 33. A more dynamic version 33
  • 35. Some tips and tricks Write unit tests before you start refactoring Code documentation (phpDoc) is your friend Don’t trust your IDE’s refactoring options 35
  • 36. Looking back What is refactoring? Why do we want to refactor? Is it the holy grail? Refactoring vs Rewriting Requirements How to do it Tips and tricks 36
  • 37. The Power of Refactoring 37
  • 38. Creative Commons Rocks! Readability: http://www.flickr.com/photos/vipulmathur/ 471634239/ (by-nc-sa/2.0) Maintainability: http://www.flickr.com/photos/sveinhal/ 2416609728/ (by-nc-nd/2.0) Extend: http://www.flickr.com/photos/ 30691679@N07/2972145815/ (by-nc-sa/2.0) Holy Grail: http://www.flickr.com/photos/joebeone/ 153921142/ (by/2.0) 38
  • 40. Thank you! Contact details: Stefan Koopmanschap http://www.leftontheweb.com/ http://www.ibuildings.com/ http://www.twitter.com/skoop http://www.slideshare.net/skoop http://joind.in/talk/view/240