Sunday, November 20, 2005

Instant Intent

I have put on sourceforge a few small fragments of code that I kept using over and over to state the intent of my code: Instant Intent.

These poor man's "testing" functions allow you to express the intent of a piece of code and later run a reality check against it. However, these days I don't like using the 'test' word, but I prefer to think in terms of intents and reality checking.

Dave Astel calls them behaviours, but I think I will stick to intent for the time being, just to avoid polluting the semantics of the concept I want to explore.

Some things you can do with intents:

expect 5, (3+2)


(3+2).should_be 5


expect_about Pi, 3.14159


expect_exception (StandardError){
puts 5/0
}

Comments:
Nice stuff. How do you use it? I have 2 alternatives in mind:
*) just to shape code and then detach
*) keeping it ala regression testing
Cheers!
 
I use it in both ways. I call the second activity reality-checking. First you define a 'reality' in language, then you keep checking the consistency of your statements about that 'reality'.

Now I am working on defining a step-by-step sequence to move from quick and rough intents and stories to terse and minimal intents. You could call it Intent Refactoring :-)
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?