Sunday, July 10, 2005

Contract First Programming

Extreme Programming (XP) is a methodology for improving programming productivity and I've borrowed lots of useful ideas from it. One such idea is "test first programming", however, I've slightly modified it to "contract first programming". Test first programming means writing tests first and then progressively coding a program against these tests until they all pass. The tests act like a building scaffold holding up your program while you build it. But unlike a building scaffold you don't have to take it all down when you finish! The test becomes part of a test suite which can help guarantee the quality of your software into the future.

But you need a plan even before you erect a scaffold. You need a scaffold for the scaffold.

This plan is the "contract" between what you're about to create and the world it is about to enter. If you can distill the contract of a program before you write it you can automatically generate large parts of the test program and the real program upfront. You can automatically scaffold both the test and the program.

But this is just beginning. When you think about it most "things" have a contract - an essential point of being - so why not create scaffolds for these too? The Goo is about sticking artefacts together but these artefacts have to be born into the world first! That's why all Goo artefacts have an accompanying "Maker" that helps distill the contract of a "Thing" and then automatically generates a scaffold for it. In the case of a computer program the Maker distills the contract of the program you're about to write and generates a test program and the program itself.

Of course Things can contain other Things. So we will need a cascading chain of Makers to erect scaffolding for all the sub-Things as well.

All "Things" in The Goo have an accompanying "Maker". A maker distills the contract of a Thing and generates a scaffold for it.

0 comments: