Agile (and XP) practices in the PHP universe

Perrick Penet, No Parking

PHP / Zend Conference, San Jose, 2006

What about your code ?

Technical debt

Legacy code

Is your code easy to change? Can you get nearly instantaneous feedback when you do change it? If the answer to any of these questions is no, you have legacy code, and it is draining time and money away from your development efforts.

Technical debt is a measure of how untidy or out-of-date the development work area for a product is. It builds up to create legacy code.

Michael Feathers : Working Effectively with Legacy Code .

Agile motto

You can invest in tools but these don't add value over time : there's no interest over time.

We value individuals and interactions over processes and tools.

Extract from the Agile Manifesto.

Preventing hair loss...

Here's probably what you want to avoid :

...and fighting spam ;-)

Here's probably what automated developer testing can do to you :

Check out other satisfied people.

Confidence and serenity are the magic words here.

You know it works, and you know when it works. So developer testing is good for you.

It may also be a nice way to fight spam at the roots.

Once we eradicate spam about hair loss, we can think of a way of making viagra a thing of the past.

XP values

Version 1.0 : Communication - Simplicity - Feedback - Courage.

Version 2.0 : Communication - Simplicity - Feedback - Courage - Respect.

XP practices (1.0)

  1. planning game
  2. small releases
  3. metaphor
  4. simple design
  5. tests (both unit and acceptance)
  6. refactoring
  1. pair programming
  2. shared code
  3. continuous integration
  4. sustainable pace
  5. on-site customer
  6. coding standards

We'll be back here... with SHIFT + ESC + h

XP practices (2.0)

XP practices (2.1)

Developers tests

A computer is dumb.

It's actually a strength, so use it.

Tip : automate.

We'll distinguish between two types of tests : unit and acceptance -- Kent Benk calls this Developer Testing.

Definition of unit test

c2 wiki

Definition of acceptance test

Also functionnal test : c2 wiki

Other tests are also possible...

Unit testing

The SimpleTest documentation and tutorial are really good (I know, I have translated them ;-). Exemples come from those : my goal today is to try and convince you reading those...


class TestOfLogging extends UnitTestCase {
    function testCreatingNewFile() {
        $log = new Log('/temp/test.log');
$test = &new TestOfLogging();
$test->run(new HtmlReporter());

What do we get?


Fail: testcreatingnewfile->True assertion failed.
1/1 test cases complete. 0 passes and 1 fails.


1/1 test cases complete. 1 passes and 0 fails.

Test driven development (TDD)

Once you've written a few test, it may seem tedious at the beginning. Then one day something incredible happen : you modify some code somewhere, then run your test suite and a red bar appears at the other end of your code. You were on the fringe of introducing a new bug and it was discovered automatically. From then on, your investment starts paying back.

You're about to become "test infected".

Writing a test before any code is now your new motto. It has a special rhythm to it :

write a test
write some code
refactor the code

Well actually, it's more something like :

write a test
write some code
write some working code
refactor messy code
refactor not-so-messy-anymore code
start again with another test

Other benefits of developer testing

For another such list : Keith Ray.

Acceptance testing

Using Selenium (a javascript-based tool driving the browser)

	<td>Logged in as : admin</td>

Broken anything yet ?

The recipe

  1. go to
  2. search for "martin fowler + refactoring"
  3. buy
  4. don't read it all
  5. start looping :
    1. detect smelling
    2. wash
    3. rince
    4. repeat

No work in progress..

...we are fighting entropy.

Go into maintenance mode.

The tube in NY has two lines for each direction : it can used 24 hours a day.

Small and frequent releases

You liked Netscape ? you'll love Vista ! The opposition (IE on the browser market and Apple / Ubuntu on the OS market) did / do release something and continued / continue to do so frequently.

Vista© ? First it was 2003 then

In the mean time, Ubuntu©

Lived happily ever after

How many times will it be "once and now" ?

$ pear update <paquet>

What do you mean "update" ?

Also a "fire and forget" mentality can be dangerous security wise :

File Transfer Pain

FTP is easy enough : can you do better ?

Secure, Simple & Heasy

Thank you so much Sara Golemon for SSH2

What do you do ?

: write
: build
: grow

Good metaphor are hard to find and event more difficult to overcome aftewards : the Desktop dates back 1968 and we haven't seen anything better yet.

Planning game

Paper based stickies : write / rub / scratch / reorder / share / look closer & further / destroy

Show don't tell

Air-bag based software development

Note : week-ends are not enough.

1 + 1 ?= 2

Question : tired or bored ?

Pair programming is draining a lot of energy : developers are constantly concentratring very hard (as-you-write compiler).

Keep it simple

Someone Is GOing TO Need It.

PHP was built upon this simplicity.

The no-framework PHP MVC framework : using a framework is expensive. Just start looking for the good one : Taking a look at ten different PHP frameworks

If you had to remember one thing : DRY, pour Don't Repeat Yourself. Then and only then, will you find out about the true power of design patterns (crutches for your language).

Next time : start with worse

To doc or not to doc

Careful, it's a trap question : documentation is very often a scape-goat.

PHP has a very good doc : the cost ?

Can you afford it ?

Get away with less

Ask your end-users and find the right dose (ie. PHPDoc is not always THE solution).

My code is your code

Note : never tell your boss about the "blame" command if you don't pair programm

Bindings between SVN and PHP do exists : sometimes very useful (as well as post-commit stuff).

Evening commit, hope. Morning update, despair.

Welcome to the green light district.

Using the green light

Some tools : CruiseControl and Rephlux

Who knows ?

He's the One you want to talk to.

Make sure He doesn't become the bottleneck.

For your eyes only

Start with PEAR "coding standards" (

class t_w_d_a() { function f() { ... return $b_number; } function __() { } } class travel_with_delta_airlines() { function wait_15_minutes_on_the_plateform() { ... return $before_it_s_too_late; } }

And think about what the rest of the world will do to you when PHP6 comes along.

Where's my stuff ?

Ruby on Rails : power to conventions fighting against power to XML based configuration in Java Wonderland.

Questions ? Queries ?

Perrick Penet

email [fr | en] :

box [fr] : No Parking

blog [fr] : :: onpk ::

contrib [en] : SimpleTest

community [fr | en] : AFUP | PHPLondon