There's a technique I've used several times which I've really come to like. I call it an Active Specification. The idea is that you write a specification for a file format or perhaps a test procedure by putting it into a method. The method delegates all messages to a helper instance variable. This allows the method to focus on the specification itself and not worry about what's being done about it. For example, a method to describe a file format could send a message for each field. One message may indicate the name, length and type of a field. Now by setting the helper variable to a file reader, you can run the method and have it read from a file using that format. If you set the variable to a writer, it can write to a file using that format. If the variable is set to a reporter, then running the method will write a report on the file format. Since the specification method only describes the specification itself, different helpers can do different operations with that specification.
Download