Posts Tagged ‘uml’

Test drive your PHP code

Monday, March 30th, 2009

Lately I’ve ventured fully submerged into the world of Test driven development (TDD).

This might start out a bit scary, especially if you have only heard about it, but never done it yourself. There is a couple of good reads on the net, so you might want to start out by familiarising yourself with this exciting way of doing things.

Have a look at http://en.wikipedia.org/wiki/Test-driven_development or Google it.

What is test driven development?

Test driven development (TDD) is more a change in coding philosophy than anything else. Some of us might say: “…yip, I’ve written a couple of unit tests when I had some spare time at the end of my project.”

To be honest, this is a bit of the wrong way round method of doing things, kind of like building a house by putting on the roof first. I think Martin Fowler describes it best when he pointed out these three components.

  • Write a test for the next bit of functionality you want to add.
  • Write the functional code until the test passes.
  • Refactor both new and old code to make it well structured.

TDD is a branch of Agile development which was based upon the first stages of extreme programming, but has really become a coding methodology that changed the way in which a lot of projects are being done.
(more…)