News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Jani Hartikainen's Blog:
Using unit tests as requirements when refactoring
September 17, 2010 @ 09:33:51

Jani Hartikainen has a suggestion for all developers out there who are working through their code and refactoring as they go - make unit tests a requirement during the process.

What should you do to make sure new code works properly when you're refactoring old code? I asked myself this question recently, when I needed to refactor a big bunch of procedural PHP code into a neat, testable, OOP-style interface. The conclusion I came into is that you should write unit tests - not to test the old code, but as requirements for the new code.

He suggests setting up a system where unit tests are set up to be where the requests are recorded - a sort of reverse TDD since you already have code to work with. Even if all of the tests aren't 100% implemented, at least you can run them and see what features you have left to do.

0 comments voice your opinion now!
unittest requirement refactor opinion tdd


blog comments powered by Disqus

Similar Posts

Paul Jones' Blog: What Does This Say About Unit-Testing in PHP Land?

DevShed: Refactoring the MySQL Abstraction Class with the Active Record Pattern

Brandon Savage's Blog: 5 (Good) Lessons The Government Teaches Us About Object-Oriented Programming

Phil Sturgeon: T_PAAMAYIM_NEKUDOTAYIM v Sanity

Sebastian Bergmann's Blog: RC2 Is The New RC1 (PHPUnit)


Community Events











Don't see your event here?
Let us know!


podcast introduction component unittest install hack performance opinion hhvm symfony2 package security database language framework facebook composer overview release application

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework