Developing the Solution


In this example, I started by trying to implement StudentDirectory through the single test you see in StudentDirectoryTest, testRandomAccess. As often happens, the task of building functionality for StudentDirectory represented a large step. As I stubbed out the methods in StudentDirectory, it led me to the task of building the DataFile class. This meant my work on Student-Directory-Test was temporarily put on hold. Similarly, after I started to work on DataFile, I found it easier to encapsulate the key functionality to a class named KeyFile.

As I progressed in developing the solution, I was constantly reevaluating the design at hand. My general strategy is to sketch an initial design going from the "outside" and moving in. In other words, I determine how client code wants to be able to use a class and base its design on that interface. If necessary, I sketch out the high-level structure and work on some of the "inner" details. No matter how I work, I find that the design is usually in a state of flux. Implementing inner details sometimes impacts the surrounding classes, and vice versa.

Changes to the design are normal. The outermost interface remains fairly stable, but the details change frequently. Few of the design changes are majorit's more like pushing small bits of code from here to there, constantly honing and improving the design.

Doing an initial design can still be very valuable. Just don't invest much time in the details. The important parts of the design to get right are the interface pointswhere does your code have to interact with other code in the system? Beyond that, the pieces in the middle are under your control. You'll craft a better system by letting the implementation guide your design.



Agile Java. Crafting Code with Test-Driven Development
Agile Javaв„ў: Crafting Code with Test-Driven Development
ISBN: 0131482394
EAN: 2147483647
Year: 2003
Pages: 391
Authors: Jeff Langr

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net