Weblog

Presentations on Slideshare

I've been doing a bit of presenting at work recently, which has meant getting my head around making up slides (using OpenOffice, of course). It all feels a little bit Dilbert, in a way.

Anyway, there's nothing particularly groundbreaking or PlayPhone-specific about these slides, so I've put them up on Slideshare in case anyone fancies a look.

The first presentation I did was on Zend Platform. Apologies for the garish yellow template.

Today's was an introduction to unit testing in PHP. It's necessarily quite introductory as it's intended for developers with little to no testing experience.

The demo code I knocked up for this one is sat over on demo.pointbeing.net.

Part 2 will be somewhat hairier, and I'll look at mocks, fixtures, some testing best-practices and a few other bits and bobs.

Posted on Friday, the 22nd of August, 2008 | permalink | comment

PHPTuring

A few years ago, as an exercise in Test-Driven Development, I wrote a Turing machine simulator in PHP and imaginatively named it PHPTuring.

I had completely forgotten about it until today, when I dug it out for another look. Truth be told, I still haven't seen a Turing machine done any better in PHP, and apart from a few syntactical niceties (removing closing PHP tags as per the Zend way, neatening up the PHPDoc blocks) I'm actually pretty comfortable with the code.

Using it is a breeze. It reads pipe-separated tapes and newline plus pipe-separated instruction sets like so:

<?php

$prog 
'0|1|1|R|0\n0||1|R|1\n1|1|1|R|1\n1|||L|2\n2|1|||stop';
$tape '1|1|1|1|1|1||1|1|1|1|1|1|1|1';

$machine  = new Machine();
$compiler = new SimpleCompiler();
$parser   = new SimpleTapeParser();
$debugger = new SimpleDebugger();

$debugger->watch($machine);

header('Content-type: text/plain');
$machine->run($compiler->compile($prog), $parser->parse($tape));

It should work with other formats, so long as someone writes parsers for them. Similarly, the debugger is just an Observer that dumps the state and tape to the screen at each step, but it could easily do something more subtle some day.

The code ships with full tests, and is available for download on PHPTuring's Sourceforge download page.

So why am I banging on about it here? I don't know. Maybe just because I like it, because it was the first afternoon's coding that really got me test-infected, and because I'd be interested in any feedback.

Posted on Monday, the 31st of March, 2008 | permalink | comment

JsUnit

Just a quick post to mention that, yes, my commitment to TDD show no signs of abating, especially in the face of the various unfamiliar technologies with which I've been working recently.

Today I came across JsUnit. Which may be old news to many, but I don't stray into JavaScript territory very often, and when I do, I'm usually quite frightened!

And how do developers reduce fear? Yup, we write some tests.

JsUnit has a nice UI, has maybe a 5 minute install/learning curve for anyone familiar with xUnits and just works. The only downsides I've found so far are that i) it doesn't work with my adored Opera and ii) some of the debugging messages are written in the sort of cryptic, broken English that suggests that the contributions of a native speaker might be welcome here.

Anyway, long story short, it's nice to know that even in the dark, dark world of client-side scripting, the gospel is spreading.

Posted on Tuesday, the 8th of May, 2007 | permalink | comment