XP test cases and message semantics

Bob Shafer bobsh at innw.net
Tue Nov 3 19:37:20 UTC 1998


[ Travis mentions, in c.l.s, that XP test cases are written *before*
the code is, and I'd rather reply here, in ramble-mode, with.... ]


       More importantly, the study of program correctness proofs has
       led to the discovery and elucidation of methods for developing
       programs. Basically, one attempts to develop a program and its
       proof hand-in-hand, with the proof ideas leading the way!

			   -David Gries, in "The Science of
                            Programming" (1981)

Extreme Programming's test cases are "proof ideas", in effect. 

These "proof ideas" Gries is discussing evolved. A program is correct
relative to its specification. A program is said, then, to satisfy its
specification: A program p satisfies its specification s, if any client
asking for s would be happy using p. (Sound like Eiffel?) 

A program can itself be seen as a specification: a program is a
specification with no "non-algorithmic" components. This induces a notion
of refinement between specifications, with the ultimate goal of refinement
being to start with a (formal) specification and, through a series of
small refinements, remove the non-algorithmic parts, resulting in a
program. Calculi and methods of program refinement were developed.

It seems to me that a Smalltalk message is a "non-algorithmic" 
specification, in the sense given above. A method satisfies/refines its
message, within the context of the receiver.

Now, a message is not exactly formal. Rather, a message is fuzzy-formal,
to coin a phrase. 

It corresponds to a fuzzy concept, not a formal, concrete one. But that's
a good thing, because that's what we think with: fuzzy concepts. 

The fuzzy is why Smalltalk is so cool. Isn't it? 

However, there are good reasons to constrain the fuzzy. The IRS is a good
reason, in the context of a payroll system. XP test cases constrain the
fuzzy, where it needs constraints, and nowhere else. Protocols constrain
the fuzzy (in a fuzzy way). Typing constrains the fuzzy (to the point of
throttling it, I'm guessing). 

One very neat thing about the fuzzy nature of messages: they are like
natural language words in that while they don't necessarily have a precise
meaning, they do have a fuzzy, shared meaning. 

Smalltalk: The programming language of common sense?





More information about the Squeak-dev mailing list