SlideShare a Scribd company logo
1 of 33
The Power of
                Refactoring
         Why doing things three times may speed up
                       development




The Power of
 Refactoring
What will we do?

  • What is refactoring?
  • Why refactoring?
  • It saves time?
  • Some examples
The Power of
 Refactoring
Introduction
  • Professional Services Consultant at
       Ibuildings
  • Secretary of Dutch PHP Usergroup
  • symfony advocate
  • husband and father (2 times)
  • 7 cats and a bunch of fish
The Power of
 Refactoring
Refactoring


The Power of
 Refactoring
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)
     The Power of
    Refactoring
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)


The Power of
 Refactoring
So basically...

  • Improve small parts of the code for...
   • Readability
   • Performance improvement
   • Implementation or change of logic
The Power of
 Refactoring
But watch out!


  • It should not break existing functionality
  • Remain a consistent API/interface

The Power of
 Refactoring
Why refactoring?

  • Prototyping
  • Unclear specs
  • Project overview
  • Improve bad code
The Power of
 Refactoring
Why refactoring?

  • Prototyping
   • Quickly have a clickable interface
   • No need for full functionality yet
   • As long as structure is OK, refactoring
           into final product is easy

The Power of
 Refactoring
Why refactoring?

  • Unclear specs
   • Something needs to be implemented
     • but you don’t know how!
   • Create a basic API and call it
   • Implement it later
The Power of
 Refactoring
Why refactoring?
  • Project overview
   • Similar to unclear specs
   • Create your project API skeleton with
           dummy responses
      • Bit by bit, work on actually adding
           functionality

The Power of
 Refactoring
Why refactoring?

  • Improve bad code (PHP4 code, anyone?)
   • Security
   • Performance
   • Best Practices
The Power of
 Refactoring
by/2.0 - Flying Cloud - http://www.flickr.com/photos/flying_cloud/

The Power of
 Refactoring
by-nc-sa/2.0 - evymoon - http://www.flickr.com/photos/evymoon_quatrain_quotidien/


The Power of
 Refactoring
Does it save time?

  • Yes! Yes it does!
   • Readability of your code
   • Maintainability of your code
   • Higher quality of your code
   • Unit testing to ensure stability
The Power of
 Refactoring
Does it save time?

  • Prototyping
   • Don’t start from scratch, use your proto
   • Only rewrite those things that really
           need it


The Power of
 Refactoring
Does it save time?

  • Unclear specs
   • Don’t write things fully until you need to
   • Think of a good API saves changing all
           calls


The Power of
 Refactoring
Does it save time?

  • Project overview
   • Know the big picture
   • Keep focus on the small part you work
           on


The Power of
 Refactoring
Does it save time?

  • Improve bad code
   • Better readability means faster coding
   • More stable code reduces bug fixing

The Power of
 Refactoring
Some requirements

  • Unit/functional tests need to be in place
   • API needs to remain exactly the same
  • API needs to be good enough
   • if not, then rewrite instead of refactor
The Power of
 Refactoring
Some examples


The Power of
 Refactoring
Project A: Unclear
                specs

  • authentication system is still unknown
  • project or iteration deadline is nearing
  • let’s first simulate the authentication

The Power of
 Refactoring
Project A: Unclear
                specs
  • Same could also apply for writing a
       prototype
      • Not all details are known
      • Short deadline
      • Doesn’t need to fully work yet
The Power of
 Refactoring
Project A: Unclear
                specs
  • Halfway the project, client finally decides
  • Easy to implement: just refactor the
       authenticate method
  • Rest of the code does not care, as long as
       you keep the API the same


The Power of
 Refactoring
Documentation helps

  •   Good rule of thumb

      •   If you need to change
          the method
          documentation,
          reconsider




The Power of
 Refactoring
Project B: Code
                improvement
  • You took over management of another
       developer’s code
  • You wrote some crappy code yourself
  • Advancements in technology made better
       things possible (much more likely! ;-)


The Power of
 Refactoring
Ensuring your API

  • Documentation
   • Changing your @param values?
   • Changing your @return value?
   • Adding/changing/removing @throws?
The Power of
 Refactoring
Ensuring your API

  • Unit Tests
   • PHPUnit/SimpleTest/lime
   • Test for all situations (also exceptions)
   • Test for the unexpected!
The Power of
 Refactoring
Ensuring your API

  • Continuous Integration
   • CruiseControl/phpUnderControl/Xinc
   • Continuously test your code
   • Alert through e-mail, SMS, Nabaztag
The Power of
 Refactoring
Further reading

  • http://www.refactoring.com/
  • http://phpimpact.wordpress.com/
       2008/09/14/code-refactoring-guidelines/
  • http://chrissterling.gettingagile.com/
       2008/10/13/refactoring-how-far-should-i-go/


The Power of
 Refactoring
Commercial break

  • http://www.leftontheweb.com/ - my
       personal blog
  • http://www.symfony-framework.nl/ - my
       dutch symfony advocacy site
  • http://www.ibuildings.com/ - my employer
       (we’re hiring! contact me!)

The Power of
 Refactoring
Questions?


The Power of
 Refactoring

More Related Content

What's hot

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
 
CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011Graham Weldon
 
Scale like a pro with Gearman
Scale like a pro with GearmanScale like a pro with Gearman
Scale like a pro with GearmanAmal Raghav
 
Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Abu Ashraf Masnun
 
Setting advanced PHP development environment
Setting advanced PHP development environmentSetting advanced PHP development environment
Setting advanced PHP development environmentKapil Sharma
 
PHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in phpPHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in phpAhmed Abdou
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsDinh Pham
 
Os Paesdosreistutorial
Os PaesdosreistutorialOs Paesdosreistutorial
Os Paesdosreistutorialoscon2007
 
Nodejs Performance Debug
Nodejs Performance DebugNodejs Performance Debug
Nodejs Performance DebugRafael Gonzaga
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvmdeimos
 
Professional PHP: an open-source alternative for enterprise development [Kort...
Professional PHP: an open-source alternative for enterprise development [Kort...Professional PHP: an open-source alternative for enterprise development [Kort...
Professional PHP: an open-source alternative for enterprise development [Kort...Combell NV
 
Performance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPPerformance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPMax Romanovsky
 
Managing Complexity with Module::Release
Managing Complexity with Module::ReleaseManaging Complexity with Module::Release
Managing Complexity with Module::Releasebrian d foy
 
Magento on HHVM. Daniel Sloof
Magento on HHVM. Daniel SloofMagento on HHVM. Daniel Sloof
Magento on HHVM. Daniel SloofMeetMagentoNY2014
 
The Beginning - Jan 20 2009
The Beginning - Jan 20 2009The Beginning - Jan 20 2009
The Beginning - Jan 20 2009Abhishek Mishra
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneDavid Glick
 
Trunk-Based Development and Toggling
Trunk-Based Development and TogglingTrunk-Based Development and Toggling
Trunk-Based Development and TogglingBryan Liu
 

What's hot (20)

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)
 
CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011
 
Scale like a pro with Gearman
Scale like a pro with GearmanScale like a pro with Gearman
Scale like a pro with Gearman
 
2021laravelconftwslides6
2021laravelconftwslides62021laravelconftwslides6
2021laravelconftwslides6
 
Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!
 
Setting advanced PHP development environment
Setting advanced PHP development environmentSetting advanced PHP development environment
Setting advanced PHP development environment
 
PHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in phpPHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in php
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applications
 
Os Paesdosreistutorial
Os PaesdosreistutorialOs Paesdosreistutorial
Os Paesdosreistutorial
 
Nodejs Performance Debug
Nodejs Performance DebugNodejs Performance Debug
Nodejs Performance Debug
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
 
Professional PHP: an open-source alternative for enterprise development [Kort...
Professional PHP: an open-source alternative for enterprise development [Kort...Professional PHP: an open-source alternative for enterprise development [Kort...
Professional PHP: an open-source alternative for enterprise development [Kort...
 
Performance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPPerformance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHP
 
Programming
ProgrammingProgramming
Programming
 
Managing Complexity with Module::Release
Managing Complexity with Module::ReleaseManaging Complexity with Module::Release
Managing Complexity with Module::Release
 
Magento on HHVM. Daniel Sloof
Magento on HHVM. Daniel SloofMagento on HHVM. Daniel Sloof
Magento on HHVM. Daniel Sloof
 
The Beginning - Jan 20 2009
The Beginning - Jan 20 2009The Beginning - Jan 20 2009
The Beginning - Jan 20 2009
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
 
CI
CICI
CI
 
Trunk-Based Development and Toggling
Trunk-Based Development and TogglingTrunk-Based Development and Toggling
Trunk-Based Development and Toggling
 

Viewers also liked

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
 
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
 
Git For Subversion Users (PHPNW11)
Git For Subversion Users (PHPNW11)Git For Subversion Users (PHPNW11)
Git For Subversion Users (PHPNW11)Stefan Koopmanschap
 
5 essential tools for the PHP Developer on Windows
5 essential tools for the PHP Developer on Windows5 essential tools for the PHP Developer on Windows
5 essential tools for the PHP Developer on WindowsStefan 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
 

Viewers also liked (6)

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
 
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)
 
Git For Subversion Users (PHPNW11)
Git For Subversion Users (PHPNW11)Git For Subversion Users (PHPNW11)
Git For Subversion Users (PHPNW11)
 
symfony 1.4 workshop
symfony 1.4 workshopsymfony 1.4 workshop
symfony 1.4 workshop
 
5 essential tools for the PHP Developer on Windows
5 essential tools for the PHP Developer on Windows5 essential tools for the PHP Developer on Windows
5 essential tools for the PHP Developer on Windows
 
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)
 

Similar to The Power Of Refactoring (PHPNW)

The Power Of Refactoring (php|tek 09)
The Power Of Refactoring (php|tek 09)The Power Of Refactoring (php|tek 09)
The Power Of Refactoring (php|tek 09)Stefan Koopmanschap
 
The Power Of Refactoring (4developers Krakow)
The Power Of Refactoring (4developers Krakow)The Power Of Refactoring (4developers Krakow)
The Power Of Refactoring (4developers Krakow)Stefan Koopmanschap
 
The Power Of Refactoring (PHPCon Italia)
The Power Of Refactoring (PHPCon Italia)The Power Of Refactoring (PHPCon Italia)
The Power Of Refactoring (PHPCon Italia)Stefan Koopmanschap
 
Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008Ivo Jansch
 
Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)Ivo Jansch
 
How To Design A Good A P I And Why It Matters G O O G L E
How To Design A Good  A P I And Why It Matters    G O O G L EHow To Design A Good  A P I And Why It Matters    G O O G L E
How To Design A Good A P I And Why It Matters G O O G L Eguestbe92f4
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + MemcachedFord AntiTrust
 
Scripting Recipes for Testers
Scripting Recipes for TestersScripting Recipes for Testers
Scripting Recipes for TestersAdam Goucher
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client DevelopmentTamir Khason
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008rajivmordani
 
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI server
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI serverPyruvate, a reasonably fast, non-blocking, multithreaded WSGI server
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI serverPloneFoundation
 
Introduction to MVC in Flex and HydraMVC
Introduction to MVC in Flex and HydraMVCIntroduction to MVC in Flex and HydraMVC
Introduction to MVC in Flex and HydraMVCcltru
 
Os Koziarsky
Os KoziarskyOs Koziarsky
Os Koziarskyoscon2007
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And MavenPerconaPerformance
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in ReactTalentica Software
 

Similar to The Power Of Refactoring (PHPNW) (20)

The Power Of Refactoring (php|tek 09)
The Power Of Refactoring (php|tek 09)The Power Of Refactoring (php|tek 09)
The Power Of Refactoring (php|tek 09)
 
The Power Of Refactoring (4developers Krakow)
The Power Of Refactoring (4developers Krakow)The Power Of Refactoring (4developers Krakow)
The Power Of Refactoring (4developers Krakow)
 
The Power Of Refactoring (PHPCon Italia)
The Power Of Refactoring (PHPCon Italia)The Power Of Refactoring (PHPCon Italia)
The Power Of Refactoring (PHPCon Italia)
 
Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008
 
Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)
 
Test
TestTest
Test
 
How To Design A Good A P I And Why It Matters G O O G L E
How To Design A Good  A P I And Why It Matters    G O O G L EHow To Design A Good  A P I And Why It Matters    G O O G L E
How To Design A Good A P I And Why It Matters G O O G L E
 
Keynoteof A P I
Keynoteof A P IKeynoteof A P I
Keynoteof A P I
 
Becoming A Php Ninja
Becoming A Php NinjaBecoming A Php Ninja
Becoming A Php Ninja
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
 
Scripting Recipes for Testers
Scripting Recipes for TestersScripting Recipes for Testers
Scripting Recipes for Testers
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client Development
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008
 
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI server
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI serverPyruvate, a reasonably fast, non-blocking, multithreaded WSGI server
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI server
 
Getting It Done
Getting It DoneGetting It Done
Getting It Done
 
Introduction to MVC in Flex and HydraMVC
Introduction to MVC in Flex and HydraMVCIntroduction to MVC in Flex and HydraMVC
Introduction to MVC in Flex and HydraMVC
 
Os Koziarsky
Os KoziarskyOs Koziarsky
Os Koziarsky
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Ivy renderer
Ivy rendererIvy renderer
Ivy renderer
 

More from 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 (phpDay 2011)
Git for Subversion Users (phpDay 2011)Git for Subversion Users (phpDay 2011)
Git for Subversion Users (phpDay 2011)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
 
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 (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
 
Myphp-busters: symfony framework (php|tek 09)
Myphp-busters: symfony framework (php|tek 09)Myphp-busters: symfony framework (php|tek 09)
Myphp-busters: symfony framework (php|tek 09)Stefan Koopmanschap
 
Symfony framework (pfCongrez 12 april 2008)
Symfony framework (pfCongrez 12 april 2008)Symfony framework (pfCongrez 12 april 2008)
Symfony framework (pfCongrez 12 april 2008)Stefan Koopmanschap
 

More from Stefan Koopmanschap (17)

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)
 
Conference Speaking 101
Conference Speaking 101Conference Speaking 101
Conference Speaking 101
 
Git for Subversion Users (phpDay 2011)
Git for Subversion Users (phpDay 2011)Git for Subversion Users (phpDay 2011)
Git for Subversion Users (phpDay 2011)
 
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)
 
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)
 
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 (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)
 
Myphp-busters: symfony framework (php|tek 09)
Myphp-busters: symfony framework (php|tek 09)Myphp-busters: symfony framework (php|tek 09)
Myphp-busters: symfony framework (php|tek 09)
 
Debugging With Symfony
Debugging With SymfonyDebugging With Symfony
Debugging With Symfony
 
Symfony framework (pfCongrez 12 april 2008)
Symfony framework (pfCongrez 12 april 2008)Symfony framework (pfCongrez 12 april 2008)
Symfony framework (pfCongrez 12 april 2008)
 

Recently uploaded

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"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
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
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
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"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...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
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
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 

The Power Of Refactoring (PHPNW)

  • 1. The Power of Refactoring Why doing things three times may speed up development The Power of Refactoring
  • 2. What will we do? • What is refactoring? • Why refactoring? • It saves time? • Some examples The Power of Refactoring
  • 3. Introduction • Professional Services Consultant at Ibuildings • Secretary of Dutch PHP Usergroup • symfony advocate • husband and father (2 times) • 7 cats and a bunch of fish The Power of Refactoring
  • 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) The Power of Refactoring
  • 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) The Power of Refactoring
  • 7. So basically... • Improve small parts of the code for... • Readability • Performance improvement • Implementation or change of logic The Power of Refactoring
  • 8. But watch out! • It should not break existing functionality • Remain a consistent API/interface The Power of Refactoring
  • 9. Why refactoring? • Prototyping • Unclear specs • Project overview • Improve bad code The Power of Refactoring
  • 10. Why refactoring? • Prototyping • Quickly have a clickable interface • No need for full functionality yet • As long as structure is OK, refactoring into final product is easy The Power of Refactoring
  • 11. Why refactoring? • Unclear specs • Something needs to be implemented • but you don’t know how! • Create a basic API and call it • Implement it later The Power of Refactoring
  • 12. Why refactoring? • Project overview • Similar to unclear specs • Create your project API skeleton with dummy responses • Bit by bit, work on actually adding functionality The Power of Refactoring
  • 13. Why refactoring? • Improve bad code (PHP4 code, anyone?) • Security • Performance • Best Practices The Power of Refactoring
  • 14. by/2.0 - Flying Cloud - http://www.flickr.com/photos/flying_cloud/ The Power of Refactoring
  • 15. by-nc-sa/2.0 - evymoon - http://www.flickr.com/photos/evymoon_quatrain_quotidien/ The Power of Refactoring
  • 16. Does it save time? • Yes! Yes it does! • Readability of your code • Maintainability of your code • Higher quality of your code • Unit testing to ensure stability The Power of Refactoring
  • 17. Does it save time? • Prototyping • Don’t start from scratch, use your proto • Only rewrite those things that really need it The Power of Refactoring
  • 18. Does it save time? • Unclear specs • Don’t write things fully until you need to • Think of a good API saves changing all calls The Power of Refactoring
  • 19. Does it save time? • Project overview • Know the big picture • Keep focus on the small part you work on The Power of Refactoring
  • 20. Does it save time? • Improve bad code • Better readability means faster coding • More stable code reduces bug fixing The Power of Refactoring
  • 21. Some requirements • Unit/functional tests need to be in place • API needs to remain exactly the same • API needs to be good enough • if not, then rewrite instead of refactor The Power of Refactoring
  • 22. Some examples The Power of Refactoring
  • 23. Project A: Unclear specs • authentication system is still unknown • project or iteration deadline is nearing • let’s first simulate the authentication The Power of Refactoring
  • 24. Project A: Unclear specs • Same could also apply for writing a prototype • Not all details are known • Short deadline • Doesn’t need to fully work yet The Power of Refactoring
  • 25. Project A: Unclear specs • Halfway the project, client finally decides • Easy to implement: just refactor the authenticate method • Rest of the code does not care, as long as you keep the API the same The Power of Refactoring
  • 26. Documentation helps • Good rule of thumb • If you need to change the method documentation, reconsider The Power of Refactoring
  • 27. Project B: Code improvement • You took over management of another developer’s code • You wrote some crappy code yourself • Advancements in technology made better things possible (much more likely! ;-) The Power of Refactoring
  • 28. Ensuring your API • Documentation • Changing your @param values? • Changing your @return value? • Adding/changing/removing @throws? The Power of Refactoring
  • 29. Ensuring your API • Unit Tests • PHPUnit/SimpleTest/lime • Test for all situations (also exceptions) • Test for the unexpected! The Power of Refactoring
  • 30. Ensuring your API • Continuous Integration • CruiseControl/phpUnderControl/Xinc • Continuously test your code • Alert through e-mail, SMS, Nabaztag The Power of Refactoring
  • 31. Further reading • http://www.refactoring.com/ • http://phpimpact.wordpress.com/ 2008/09/14/code-refactoring-guidelines/ • http://chrissterling.gettingagile.com/ 2008/10/13/refactoring-how-far-should-i-go/ The Power of Refactoring
  • 32. Commercial break • http://www.leftontheweb.com/ - my personal blog • http://www.symfony-framework.nl/ - my dutch symfony advocacy site • http://www.ibuildings.com/ - my employer (we’re hiring! contact me!) The Power of Refactoring
  • 33. Questions? The Power of Refactoring