SlideShare a Scribd company logo
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

More Related Content

What's hot

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
Tró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 Economics
Perforce
 
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 - Sydney
Abhinav 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, 2014
Endava
 
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ên
Nexus FrontierTech
 
Automating development-operations-v1
Automating development-operations-v1Automating development-operations-v1
Automating development-operations-v1Sumanth Vepa
 
Xp conf-tbd
Xp conf-tbdXp conf-tbd
Xp conf-tbd
XP Conference India
 
BDD and Behave
BDD and BehaveBDD and Behave
BDD and Behave
Adam Englander
 
JIRA & Stach, The Love Story
JIRA & Stach, The Love StoryJIRA & Stach, The Love Story
JIRA & Stach, The Love Story
Atlassian 대한민국
 
プレゼンビフォアアフタ
プレゼンビフォアアフタプレゼンビフォアアフタ
プレゼンビフォアアフタ
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 Delivery
anistar 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 2016
Lemi 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ôi
Nexus FrontierTech
 
Build Automation in Android
Build Automation in AndroidBuild Automation in Android
Build Automation in Android
Angelo Rüggeberg
 
Why I Love Ruby On Rails
Why I Love Ruby On RailsWhy I Love Ruby On Rails
Why I Love Ruby On Rails
Raimonds Simanovskis
 
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
Evolve The Adobe Digital Marketing Community
 
More than Programming!
More than Programming!More than Programming!
More than Programming!Sophy Eung
 

What's hot (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 to The Power Of Refactoring (4developers Krakow)

The Power of Refactoring
The Power of RefactoringThe Power of Refactoring
The Power of Refactoring
Stefan Koopmanschap
 
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 language
Marco Cedaro
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
Itzik Saban
 
Test Driven Design
Test Driven DesignTest Driven Design
Test Driven Design
Saad Ahmed
 
Code refactoring
Code refactoringCode refactoring
Code refactoring
Lalit Kale
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
Jacob Kaplan-Moss
 
Software reengineering for Developers
Software reengineering for DevelopersSoftware reengineering for Developers
Software reengineering for Developers
Bradley Irby
 
Refactoring, Emergent Design & Evolutionary Architecture
Refactoring, Emergent Design & Evolutionary ArchitectureRefactoring, Emergent Design & Evolutionary Architecture
Refactoring, Emergent Design & Evolutionary Architecture
Brad Appleton
 
Refactoring 2 The Max
Refactoring 2 The MaxRefactoring 2 The Max
Refactoring 2 The Max
Alfredo Morresi
 
Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in RefactoringChamnap Chhorn
 
Architecture in real
Architecture in realArchitecture in real
Architecture in real
Michael 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 Specs
Atlassian
 
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
Manuel Rivero
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
Boris Dominic
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An Introduction
Giorgio 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 Scale
Adrian Perreau de Pinninck
 

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

More from Stefan Koopmanschap

A Practical Look At Symfony2
A Practical Look At Symfony2A Practical Look At Symfony2
A Practical Look At Symfony2
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
 
Conference Speaking 101
Conference Speaking 101Conference Speaking 101
Conference Speaking 101
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 Webinar
Stefan 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
 
Git Workshop (Pfz Workshopdag)
Git Workshop (Pfz Workshopdag)Git Workshop (Pfz Workshopdag)
Git Workshop (Pfz Workshopdag)
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
 
symfony 1.4 workshop
symfony 1.4 workshopsymfony 1.4 workshop
symfony 1.4 workshop
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) help
Stefan 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 Framework
Stefan Koopmanschap
 
Scrum (dutch)
Scrum (dutch)Scrum (dutch)
Scrum (dutch)
Stefan Koopmanschap
 

More from 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)
 

Recently uploaded

AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 

Recently uploaded (20)

AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 

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