- Write a test.
- Make it run.
- Make it right.
Again, "get to green quickly" implying that we are going to transition from the design we have to the design we want via many more much smaller steps.
Beck offers "architecture driven development" as a label for the opposite approach, where implementing the clean design happens before we can know whether the clean design will in fact work the problem. I don't love the name, and to be honest I'm not sure there's that much advantage in pretending that we don't know what the final design is going to look like.
I might argue as well that "invent the interface you wish you had" sounds to me a lot like solving the clean code part first. If we can train our brains to do that well, why not the other? Of course, Kent immediately takes the same view, but reversed
Our guesses about the right interface are no more likely to be perfect than our guesses about the right implementation.
But fine - sometimes we have to go back and change up the interface -- which is one reason that we implement a new failing test only when there are no other failing tests; we don't want to make extra work for ourselves by over committing when we know the least about our final design.
Something I notice: for this second chapter, Beck extends his original test into a more complicated scenario, rather than introducing a new test. That's fine, I guess - I'm not sure I remember when disciplined assertions became a thing.
The longer I do this, the better able I am to translate my aesthetic judgments into tests. When I can do this, my design discussions become much more interesting.
What catches my attention here is the sequence: judgment, test, implementation. In this example, Kent doesn't wait until a mistake "discovers" that a different design would be easier to work with in the long term, but instead motivates his code change via "that's doesn't work how I want it to". And without a doubt, I think treating this Dollar implementation as an immutable value is reasonable.
But there's certainly no "the test told us to do it" here. This design change comes about because we're all carrying memories of designs that made things unnecessarily difficult, and we have no particular interest in repeating the experience.
No comments:
Post a Comment