Story of Advancers

Brian Marick says, I'm especially interested in the stories that peers tell each other to reinforce a style of working and body of practical knowledge. Ward's story of "method object" is a good example. post

# Problem

Complex tests can find bugs in complex code. What then? Usually, the result is an unending struggle against entropy: a continuous effort to fix bugs in unyielding code, hoping that each fix doesn't generate another bug. Once upon a time, Ward Cunningham was mired in entropy, but what happened next makes an unusual story.

His team was working on a bond trading application. It was to have two advantages over its competition. First, input would be more pleasant. Second, users would be able to generate reports on a position (a collection of holdings) as of any date.

The latter proved hard to do. Many bug fixes later, one method in particular was clearly a problem. It was the one that advanced a position to a new date by processing all related transactions. It had grown to a convoluted mess of code, one that proved remarkably hard to clean up. The solution was to convert the method into a Method Object.

# Solution

It's common to treat method objects as just a coding convenience. But Cunningham's team found themselves treating this one as a design tool. They gave it a name - Advancer - that sounded like one from the domain (though none of the domain experts had a corresponding notion). Once Advancers were part of their design vocabulary, thinking about how to satisfy a new requirement meant, in part, thinking about whether a special kind of Advancer might fit nicely. By changing the way they thought about the domain, the team was able to write better code faster.

# Bonus

Advancers later helped out in another way. The program calculated tax reports. What the government wanted was described in terms of positions and portfolios, so the calculations were implemented by Position and Portfolio objects. But there were always nagging bugs. Some time after Advancers came on the scene, the team realized they were the right place for the calculation: it happened that Advancers had instance variables that contained exactly the information needed. Switching to Advancers made tax reports tractable.

It was only in later years that Cunningham realized why tax calculations had been so troublesome. The government and traders had different interests. The traders cared most about their positions, whereas the government cared most about how traders came to have them. It's that latter idea that Advancers captured, but conversations with domain experts couldn't tease it out - even tax experts didn't know how to express it that way. It only came out through a conversation with the code.

.

The old story may have significance in light of modern interpretation of brain activity. The small team had learned Smalltalk by the book and by browsing the code that made Smalltalk do what it did. This was a middle ground between what I've called book vs. query learning.

The solution came from strongly sensory analysis including colored pencil paths marked on three feet of printout. The method object deserved a name but we found none and settled for the descriptive noun Advancer for thing that advances positions through time.

Acceptance of this marginal quality name came from our contemplation of its role in the collection of object that was our program. We were truly surprised when this device invented to straighten out colored pencil lines taught us something about the traders we served and the tax collectors they had to satisfy.

We might guess that the salient features of the problems we faced were external for the colored lines and internal for imagining what our customers wanted. We flopped regularly in and out between these modes of thought for months before the whole solution became clear and convincing.

.

Mathias Verraes and Rebecca Wirfs-Brock tell a story of discovering an abstraction called Alert Condition. The story finds similar insight from programmers carefully considering the software implications of the messy reality of an explosion on an oil rig. See Design and Reality.