SlideShare uma empresa Scribd logo
1 de 42
The Power of
                Refactoring
         Why doing things three times may speed up
                       development




The Power of
 Refactoring
What will we do?

  • Intro
  • 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
Refactoring v Rewriting

  • Refactoring
   • Consistent API
   • Internal logic changes
   • No need to alter unit tests or API docs
The Power of
 Refactoring
Refactoring v Rewriting

  • Rewriting
   • Refactoring won’t help you anymore
   • More complex: alter unit tests, alter
           calling code, alter documentation


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-nc/2.0 - gilest - http://www.flickr.com/photos/gilest/

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




The Power of
 Refactoring
Project A: Unclear
                specs




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
Project A: Unclear
                specs




The Power of
 Refactoring
Nothing changes


  •   This still works!




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
Project B: Code
                improvement




The Power of
 Refactoring
Project B: Code
                improvement




The Power of
 Refactoring
Nothing changes


  •   This still works!




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

Mais conteúdo relacionado

Mais procurados

CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011Graham Weldon
 
Essential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricksEssential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricksKaloyan Raev
 
Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008Ivo Jansch
 
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
 
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
 
Os Paesdosreistutorial
Os PaesdosreistutorialOs Paesdosreistutorial
Os Paesdosreistutorialoscon2007
 
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
 
Nodejs Performance Debug
Nodejs Performance DebugNodejs Performance Debug
Nodejs Performance DebugRafael Gonzaga
 
An introduction to Titanium
An introduction to TitaniumAn introduction to Titanium
An introduction to TitaniumGraham Weldon
 
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
 
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
 
Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)Patrick Allaert
 

Mais procurados (20)

CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011
 
Essential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricksEssential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricks
 
Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008
 
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
 
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
 
Os Paesdosreistutorial
Os PaesdosreistutorialOs Paesdosreistutorial
Os Paesdosreistutorial
 
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
 
Nodejs Performance Debug
Nodejs Performance DebugNodejs Performance Debug
Nodejs Performance Debug
 
An introduction to Titanium
An introduction to TitaniumAn introduction to Titanium
An introduction to Titanium
 
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...
 
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
 
Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)
 

Destaque

What’s your take
What’s your takeWhat’s your take
What’s your takekklosemd
 
COMO ESTUDIAR EN LA MODALIDAD METODOLOGÍA A DISTANCIA
COMO ESTUDIAR EN LA MODALIDAD METODOLOGÍA A DISTANCIACOMO ESTUDIAR EN LA MODALIDAD METODOLOGÍA A DISTANCIA
COMO ESTUDIAR EN LA MODALIDAD METODOLOGÍA A DISTANCIAHanner Navarro
 
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
 
Mapa regularização 1 tm bahia 2016
Mapa regularização 1 tm bahia 2016Mapa regularização 1 tm bahia 2016
Mapa regularização 1 tm bahia 2016Paulo Carneiro
 
Tecnologias No Cotidiano
Tecnologias No CotidianoTecnologias No Cotidiano
Tecnologias No Cotidianoguest12fbd1
 
Fuentes de información y busquedas bibliográficas
Fuentes de información y busquedas bibliográficasFuentes de información y busquedas bibliográficas
Fuentes de información y busquedas bibliográficasUrbano Vázquez Fernández
 
Teamlead - О нас
Teamlead - О насTeamlead - О нас
Teamlead - О насTeamlead
 
A - Bio Data - Mr. Sajt Samuel
A - Bio Data - Mr. Sajt SamuelA - Bio Data - Mr. Sajt Samuel
A - Bio Data - Mr. Sajt SamuelSajit Samuel
 
Aug 3-2012 - ALM Works - AtlasCamp 2012
Aug 3-2012 - ALM Works - AtlasCamp 2012Aug 3-2012 - ALM Works - AtlasCamp 2012
Aug 3-2012 - ALM Works - AtlasCamp 2012Teamlead
 
Jay´s and Ryen´s project
Jay´s and Ryen´s projectJay´s and Ryen´s project
Jay´s and Ryen´s projectNoeliaRG
 
Adicciones
AdiccionesAdicciones
Adiccionesguadaana
 
презентація досвіду роботи вчителя історії
презентація досвіду роботи вчителя історіїпрезентація досвіду роботи вчителя історії
презентація досвіду роботи вчителя історіїschoolperem1984
 
Continents tema 1
Continents tema 1Continents tema 1
Continents tema 1Isa Signes
 

Destaque (20)

What’s your take
What’s your takeWhat’s your take
What’s your take
 
COMO ESTUDIAR EN LA MODALIDAD METODOLOGÍA A DISTANCIA
COMO ESTUDIAR EN LA MODALIDAD METODOLOGÍA A DISTANCIACOMO ESTUDIAR EN LA MODALIDAD METODOLOGÍA A DISTANCIA
COMO ESTUDIAR EN LA MODALIDAD METODOLOGÍA A DISTANCIA
 
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)
 
Mapa regularização 1 tm bahia 2016
Mapa regularização 1 tm bahia 2016Mapa regularização 1 tm bahia 2016
Mapa regularização 1 tm bahia 2016
 
Tecnologias No Cotidiano
Tecnologias No CotidianoTecnologias No Cotidiano
Tecnologias No Cotidiano
 
Conference Speaking 101
Conference Speaking 101Conference Speaking 101
Conference Speaking 101
 
A Bao A
A Bao AA Bao A
A Bao A
 
Curologic - Corporate Profile
Curologic - Corporate ProfileCurologic - Corporate Profile
Curologic - Corporate Profile
 
Fuentes de información y busquedas bibliográficas
Fuentes de información y busquedas bibliográficasFuentes de información y busquedas bibliográficas
Fuentes de información y busquedas bibliográficas
 
Marxem de colònies!
Marxem de colònies!Marxem de colònies!
Marxem de colònies!
 
Teamlead - О нас
Teamlead - О насTeamlead - О нас
Teamlead - О нас
 
Aula5 joao
Aula5 joaoAula5 joao
Aula5 joao
 
A - Bio Data - Mr. Sajt Samuel
A - Bio Data - Mr. Sajt SamuelA - Bio Data - Mr. Sajt Samuel
A - Bio Data - Mr. Sajt Samuel
 
Aug 3-2012 - ALM Works - AtlasCamp 2012
Aug 3-2012 - ALM Works - AtlasCamp 2012Aug 3-2012 - ALM Works - AtlasCamp 2012
Aug 3-2012 - ALM Works - AtlasCamp 2012
 
Jay´s and Ryen´s project
Jay´s and Ryen´s projectJay´s and Ryen´s project
Jay´s and Ryen´s project
 
Romenia
RomeniaRomenia
Romenia
 
Introductie JIRA en Confluence bij Sanoma Media
Introductie JIRA en Confluence bij Sanoma MediaIntroductie JIRA en Confluence bij Sanoma Media
Introductie JIRA en Confluence bij Sanoma Media
 
Adicciones
AdiccionesAdicciones
Adicciones
 
презентація досвіду роботи вчителя історії
презентація досвіду роботи вчителя історіїпрезентація досвіду роботи вчителя історії
презентація досвіду роботи вчителя історії
 
Continents tema 1
Continents tema 1Continents tema 1
Continents tema 1
 

Semelhante a The Power of Refactoring

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 (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
 
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
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008rajivmordani
 
Scripting Recipes for Testers
Scripting Recipes for TestersScripting Recipes for Testers
Scripting Recipes for TestersAdam Goucher
 
Os Koziarsky
Os KoziarskyOs Koziarsky
Os Koziarskyoscon2007
 
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At CommercetoolsGraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At CommercetoolsNicola Molinari
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in ReactTalentica Software
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client DevelopmentTamir Khason
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + MemcachedFord AntiTrust
 

Semelhante a The Power of Refactoring (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 (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
 
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
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008
 
Becoming A Php Ninja
Becoming A Php NinjaBecoming A Php Ninja
Becoming A Php Ninja
 
CI
CICI
CI
 
Getting It Done
Getting It DoneGetting It Done
Getting It Done
 
Scripting Recipes for Testers
Scripting Recipes for TestersScripting Recipes for Testers
Scripting Recipes for Testers
 
Os Koziarsky
Os KoziarskyOs Koziarsky
Os Koziarsky
 
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At CommercetoolsGraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
 
Ivy renderer
Ivy rendererIvy renderer
Ivy renderer
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client Development
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
 
Seminar - JBoss Migration
Seminar - JBoss MigrationSeminar - JBoss Migration
Seminar - JBoss Migration
 

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

Mais 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)
 
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 (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)
 
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
 
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
 

Último

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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
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
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
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
 
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
 
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
 
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
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
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
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Último (20)

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...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
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
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
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
 
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
 
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
 
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
 
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
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
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
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

The Power of Refactoring

  • 1. The Power of Refactoring Why doing things three times may speed up development The Power of Refactoring
  • 2. What will we do? • Intro • 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. Refactoring v Rewriting • Refactoring • Consistent API • Internal logic changes • No need to alter unit tests or API docs The Power of Refactoring
  • 10. Refactoring v Rewriting • Rewriting • Refactoring won’t help you anymore • More complex: alter unit tests, alter calling code, alter documentation The Power of Refactoring
  • 11. Why refactoring? • Prototyping • Unclear specs • Project overview • Improve bad code The Power of Refactoring
  • 12. 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
  • 13. 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
  • 14. 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
  • 15. Why refactoring? • Improve bad code (PHP4 code, anyone?) • Security • Performance • Best Practices The Power of Refactoring
  • 16. by-nc/2.0 - gilest - http://www.flickr.com/photos/gilest/ The Power of Refactoring
  • 17. by-nc-sa/2.0 - evymoon - http://www.flickr.com/photos/evymoon_quatrain_quotidien/ The Power of Refactoring
  • 18. 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
  • 19. 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
  • 20. 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
  • 21. Does it save time? • Project overview • Know the big picture • Keep focus on the small part you work on The Power of Refactoring
  • 22. Does it save time? • Improve bad code • Better readability means faster coding • More stable code reduces bug fixing The Power of Refactoring
  • 23. 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
  • 24. Some examples The Power of Refactoring
  • 25. 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
  • 26. 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
  • 27. Project A: Unclear specs The Power of Refactoring
  • 28. Project A: Unclear specs The Power of Refactoring
  • 29. 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
  • 30. Project A: Unclear specs The Power of Refactoring
  • 31. Nothing changes • This still works! The Power of Refactoring
  • 32. Documentation helps • Good rule of thumb • If you need to change the method documentation, reconsider The Power of Refactoring
  • 33. 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
  • 34. Project B: Code improvement The Power of Refactoring
  • 35. Project B: Code improvement The Power of Refactoring
  • 36. Nothing changes • This still works! The Power of Refactoring
  • 37. Ensuring your API • Documentation • Changing your @param values? • Changing your @return value? • Adding/changing/removing @throws? The Power of Refactoring
  • 38. Ensuring your API • Unit Tests • PHPUnit/SimpleTest/lime • Test for all situations (also exceptions) • Test for the unexpected! The Power of Refactoring
  • 39. Ensuring your API • Continuous Integration • CruiseControl/phpUnderControl/Xinc • Continuously test your code • Alert through e-mail, SMS, Nabaztag The Power of Refactoring
  • 40. 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
  • 41. 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
  • 42. Questions? The Power of Refactoring