SlideShare una empresa de Scribd logo
1 de 39
Descargar para leer sin conexión
The Power of Refactoring




                 Stefan Koopmanschap
    4developers, Krakow, March 7 2009
What will we do?

 What is refactoring?
 Why refactoring?
 Requirements
 HOWTO




                        2
Stefan Koopmanschap
Who is he?




                      3
About me

 Professional Services Consultant at Ibuildings
 10 years of PHP experience
 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/change/implement




                          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




                      15
Refactor vs Rewrite

 Refactor whenever it is possible




                                    15
Refactor vs Rewrite

 Refactor whenever it is possible
 Big change? Try to cut it into smaller units




                                                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!




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




               21
Unit testing

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




                                                   22
An example
user authentication




                      23
A test-driven approach




                         24
My first implementation




                          25
My first implementation




                          25
A more dynamic version




                         26
A more dynamic version




                         26
Tips and tricks




                  27
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




                                                 28
Will you refactor now?




                         29
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




                               30
Creative Commons Rocks!
Readability:
http://www.flickr.com/photos/vipulmathur/
471634239/ (by-nc-sa/2.0)
Maintainability:
http://www.flickr.com/photos/comicbase/
2117680144/ (by-nc-sa/2.0)
Extend:
http://www.flickr.com/photos/auntiep/
221951988/ (by-nc-sa/2.0)
Holy Grail:
http://www.flickr.com/photos/joebeone/
153921142/ (by/2.0)
Würst test ever:
http://www.flickr.com/photos/pingles/
1341229619/ (by-nc-nd/2.0)

                                            31
Questions ?




              32
Thank you!
                Contact details:
           Stefan Koopmanschap
  http://www.leftontheweb.com/
      http://www.ibuildings.com/
   http://www.twitter.com/skoop
http://www.slideshare.net/skoop

Más contenido relacionado

La actualidad más candente

TGT#20 - Automated Tests Only For Testers - Kasper Kulikowski
TGT#20 - Automated Tests Only For Testers - Kasper KulikowskiTGT#20 - Automated Tests Only For Testers - Kasper Kulikowski
TGT#20 - Automated Tests Only For Testers - Kasper KulikowskiTrójmiejska Grupa Testerska
 
Trunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and EconomicsTrunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and EconomicsPerforce
 
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...VincitOy
 
Testing and beyond at startups
Testing and beyond at startupsTesting and beyond at startups
Testing and beyond at startupsMona Soni
 
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - SydneySimplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - SydneyAbhinav Gupta
 
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014Endava
 
Branching and Merging Practices
Branching and Merging Practices Branching and Merging Practices
Branching and Merging Practices Rajesh Kumar
 
Tech Talk #5 : CI/CD FOR MOBILE DEVELOPMENT - Đinh Ngọc Kiên
Tech Talk #5 : CI/CD FOR MOBILE DEVELOPMENT - Đinh Ngọc KiênTech Talk #5 : CI/CD FOR MOBILE DEVELOPMENT - Đinh Ngọc Kiên
Tech Talk #5 : CI/CD FOR MOBILE DEVELOPMENT - Đinh Ngọc KiênNexus FrontierTech
 
Automating development-operations-v1
Automating development-operations-v1Automating development-operations-v1
Automating development-operations-v1Sumanth Vepa
 
プレゼンビフォアアフタ
プレゼンビフォアアフタプレゼンビフォアアフタ
プレゼンビフォアアフタTsuyoshi Ushio
 
MOPCON 2015 - Tips of Mobile Continuous Delivery
MOPCON 2015 - Tips of Mobile Continuous DeliveryMOPCON 2015 - Tips of Mobile Continuous Delivery
MOPCON 2015 - Tips of Mobile Continuous Deliveryanistar sung
 
Test Driven Design - GDG DevFest Istanbul 2016
Test Driven Design - GDG DevFest Istanbul 2016Test Driven Design - GDG DevFest Istanbul 2016
Test Driven Design - GDG DevFest Istanbul 2016Lemi Orhan Ergin
 
Tech Talk #5 : Apply CI tools in iOS development - Trương Minh Khôi
Tech Talk #5 : Apply	CI tools in iOS	development - Trương Minh KhôiTech Talk #5 : Apply	CI tools in iOS	development - Trương Minh Khôi
Tech Talk #5 : Apply CI tools in iOS development - Trương Minh KhôiNexus FrontierTech
 
More than Programming!
More than Programming!More than Programming!
More than Programming!Sophy Eung
 

La actualidad más candente (20)

TGT#20 - Automated Tests Only For Testers - Kasper Kulikowski
TGT#20 - Automated Tests Only For Testers - Kasper KulikowskiTGT#20 - Automated Tests Only For Testers - Kasper Kulikowski
TGT#20 - Automated Tests Only For Testers - Kasper Kulikowski
 
Trunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and EconomicsTrunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and Economics
 
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
 
Testing and beyond at startups
Testing and beyond at startupsTesting and beyond at startups
Testing and beyond at startups
 
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - SydneySimplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
 
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014
Continuos integration with Jenkins for iOS | SuperSpeakers@CodeCamp Iasi, 2014
 
Branching and Merging Practices
Branching and Merging Practices Branching and Merging Practices
Branching and Merging Practices
 
Tech Talk #5 : CI/CD FOR MOBILE DEVELOPMENT - Đinh Ngọc Kiên
Tech Talk #5 : CI/CD FOR MOBILE DEVELOPMENT - Đinh Ngọc KiênTech Talk #5 : CI/CD FOR MOBILE DEVELOPMENT - Đinh Ngọc Kiên
Tech Talk #5 : CI/CD FOR MOBILE DEVELOPMENT - Đinh Ngọc Kiên
 
Automating development-operations-v1
Automating development-operations-v1Automating development-operations-v1
Automating development-operations-v1
 
Xp conf-tbd
Xp conf-tbdXp conf-tbd
Xp conf-tbd
 
BDD and Behave
BDD and BehaveBDD and Behave
BDD and Behave
 
JIRA & Stach, The Love Story
JIRA & Stach, The Love StoryJIRA & Stach, The Love Story
JIRA & Stach, The Love Story
 
プレゼンビフォアアフタ
プレゼンビフォアアフタプレゼンビフォアアフタ
プレゼンビフォアアフタ
 
MOPCON 2015 - Tips of Mobile Continuous Delivery
MOPCON 2015 - Tips of Mobile Continuous DeliveryMOPCON 2015 - Tips of Mobile Continuous Delivery
MOPCON 2015 - Tips of Mobile Continuous Delivery
 
Test Driven Design - GDG DevFest Istanbul 2016
Test Driven Design - GDG DevFest Istanbul 2016Test Driven Design - GDG DevFest Istanbul 2016
Test Driven Design - GDG DevFest Istanbul 2016
 
Tech Talk #5 : Apply CI tools in iOS development - Trương Minh Khôi
Tech Talk #5 : Apply	CI tools in iOS	development - Trương Minh KhôiTech Talk #5 : Apply	CI tools in iOS	development - Trương Minh Khôi
Tech Talk #5 : Apply CI tools in iOS development - Trương Minh Khôi
 
Build Automation in Android
Build Automation in AndroidBuild Automation in Android
Build Automation in Android
 
Why I Love Ruby On Rails
Why I Love Ruby On RailsWhy I Love Ruby On Rails
Why I Love Ruby On Rails
 
EVOLVE'15 | Enhance | Rene Ugarte | AEM Quality Assurance
EVOLVE'15 | Enhance | Rene Ugarte | AEM Quality AssuranceEVOLVE'15 | Enhance | Rene Ugarte | AEM Quality Assurance
EVOLVE'15 | Enhance | Rene Ugarte | AEM Quality Assurance
 
More than Programming!
More than Programming!More than Programming!
More than Programming!
 

Similar a The Power Of Refactoring (4developers Krakow)

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
 
Paris Web - Javascript as a programming language
Paris Web - Javascript as a programming languageParis Web - Javascript as a programming language
Paris Web - Javascript as a programming languageMarco Cedaro
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop Itzik Saban
 
Test Driven Design
Test Driven DesignTest Driven Design
Test Driven DesignSaad Ahmed
 
Code refactoring
Code refactoringCode refactoring
Code refactoringLalit Kale
 
Software reengineering for Developers
Software reengineering for DevelopersSoftware reengineering for Developers
Software reengineering for DevelopersBradley Irby
 
Refactoring, Emergent Design & Evolutionary Architecture
Refactoring, Emergent Design & Evolutionary ArchitectureRefactoring, Emergent Design & Evolutionary Architecture
Refactoring, Emergent Design & Evolutionary ArchitectureBrad Appleton
 
Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in RefactoringChamnap Chhorn
 
Architecture in real
Architecture in realArchitecture in real
Architecture in realMichael Chen
 
10 Tips for Configuring Your Builds with Bamboo Specs
10 Tips for Configuring Your Builds with Bamboo Specs10 Tips for Configuring Your Builds with Bamboo Specs
10 Tips for Configuring Your Builds with Bamboo SpecsAtlassian
 
Effects, Coeffects & Subscriptions: a pit of success for SPAs
Effects, Coeffects & Subscriptions: a pit of success for SPAsEffects, Coeffects & Subscriptions: a pit of success for SPAs
Effects, Coeffects & Subscriptions: a pit of success for SPAsManuel Rivero
 
Continuous integration
Continuous integrationContinuous integration
Continuous integrationBoris Dominic
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An IntroductionGiorgio Vespucci
 
Simplifying the OpenAPI Development Experience
Simplifying the OpenAPI Development Experience Simplifying the OpenAPI Development Experience
Simplifying the OpenAPI Development Experience confluent
 
Delivery at Scale
Delivery at ScaleDelivery at Scale
Delivery at ScaleAgilar
 

Similar a The Power Of Refactoring (4developers Krakow) (20)

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)
 
Refactoring
RefactoringRefactoring
Refactoring
 
The View - Lotusscript coding best practices
The View - Lotusscript coding best practicesThe View - Lotusscript coding best practices
The View - Lotusscript coding best practices
 
Paris Web - Javascript as a programming language
Paris Web - Javascript as a programming languageParis Web - Javascript as a programming language
Paris Web - Javascript as a programming language
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
 
Test Driven Design
Test Driven DesignTest Driven Design
Test Driven Design
 
Code refactoring
Code refactoringCode refactoring
Code refactoring
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
 
Software reengineering for Developers
Software reengineering for DevelopersSoftware reengineering for Developers
Software reengineering for Developers
 
Refactoring, Emergent Design & Evolutionary Architecture
Refactoring, Emergent Design & Evolutionary ArchitectureRefactoring, Emergent Design & Evolutionary Architecture
Refactoring, Emergent Design & Evolutionary Architecture
 
Refactoring 2 The Max
Refactoring 2 The MaxRefactoring 2 The Max
Refactoring 2 The Max
 
Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in Refactoring
 
Architecture in real
Architecture in realArchitecture in real
Architecture in real
 
10 Tips for Configuring Your Builds with Bamboo Specs
10 Tips for Configuring Your Builds with Bamboo Specs10 Tips for Configuring Your Builds with Bamboo Specs
10 Tips for Configuring Your Builds with Bamboo Specs
 
Effects, Coeffects & Subscriptions: a pit of success for SPAs
Effects, Coeffects & Subscriptions: a pit of success for SPAsEffects, Coeffects & Subscriptions: a pit of success for SPAs
Effects, Coeffects & Subscriptions: a pit of success for SPAs
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An Introduction
 
Simplifying the OpenAPI Development Experience
Simplifying the OpenAPI Development Experience Simplifying the OpenAPI Development Experience
Simplifying the OpenAPI Development Experience
 
Delivery at Scale
Delivery at ScaleDelivery at Scale
Delivery at Scale
 

Más 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
 

Más 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)
 

Último

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Último (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

The Power Of Refactoring (4developers Krakow)

  • 1. The Power of Refactoring Stefan Koopmanschap 4developers, Krakow, March 7 2009
  • 2. What will we do? What is refactoring? Why refactoring? Requirements HOWTO 2
  • 4. About me Professional Services Consultant at Ibuildings 10 years of PHP experience 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
  • 16. Refactor vs Rewrite Refactor whenever it is possible 15
  • 17. Refactor vs Rewrite Refactor whenever it is possible Big change? Try to cut it into smaller units 15
  • 18. 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! 15
  • 19. 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
  • 20. 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
  • 22. Requirements Codebase knowledge Structured API Unit testing 18
  • 23. Codebase knowledge Know what to change quickly Be aware of your changes Be aware of impact of your changes on other components 19
  • 24. 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
  • 26. Unit testing Unit testing is your first point of QA They safeguard you from unexpected side effects Test - Change - Test 22
  • 31. A more dynamic version 26
  • 32. A more dynamic version 26
  • 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 28
  • 35. Will you refactor now? 29
  • 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 30
  • 37. Creative Commons Rocks! Readability: http://www.flickr.com/photos/vipulmathur/ 471634239/ (by-nc-sa/2.0) Maintainability: http://www.flickr.com/photos/comicbase/ 2117680144/ (by-nc-sa/2.0) Extend: http://www.flickr.com/photos/auntiep/ 221951988/ (by-nc-sa/2.0) Holy Grail: http://www.flickr.com/photos/joebeone/ 153921142/ (by/2.0) Würst test ever: http://www.flickr.com/photos/pingles/ 1341229619/ (by-nc-nd/2.0) 31
  • 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