Java Reference
In-Depth Information
developed through the CRC card activities earlier). As you review the classes in the taxi-
company-outline project, you may feel that we have gone too far in this case, or maybe even
not far enough. On the positive side, by attempting to create a version that at least compiles, we
certainly found that we were forced to think about the Vehicle inheritance hierarchy in some
detail: in particular, which methods could be implemented in full in the superclass and which
were best left as abstract. On the negative side, there is always the risk of making implementa-
tion decisions too early: for instance, committing to particular sorts of data structures that might
be better left until later or, as we did here, choosing to reject the Observer pattern in favor of the
more direct approach.
Exercise 14.12 For each of the classes in the project, look at the class interface and write a
list of JUnit tests that should be used to test the functionality of the class.
Exercise 14.13 The taxi-company-outline project defines a Demo class to create a pair of
PassengerSource and TaxiCompany objects. Create a Demo object and try its pickup-
Test method. Why is the TaxiCompany object unable to grant a pickup request at this stage?
Exercise 14.14 Do you feel that we should have developed the source code further at this
stage, to enable at least one pickup request to succeed? If so, how much further would you
have taken the development?
14.3.4
Testing
Having made a start on implementation, we should not go too much further before we start to
consider how we shall test the application. We do not want to make the mistake of devising tests
only once the full implementation is complete. We can already put some tests in place that will
gradually evolve as the implementation is evolved. Try the following exercises to get a feel for
what is possible at this early stage.
Exercise 14.15 The taxi-company-outline-testing project includes some simple initial JUnit
tests. Try them out. Add any further tests you feel are appropriate at this stage of the develop-
ment, to form the basis of a set of tests to be used during future development. Does it matter if
the tests we create fail at this stage?
Exercise 14.16 The Location class currently contains no fields or methods. How is fur-
ther development of this class likely to affect existing test classes?
14.3.5
Some remaining issues
One of the major issues that we have not attempted to tackle yet is how to organize the sequenc-
ing of the various activities: passenger requests, vehicle movements, and so on. Another is that
locations have not been given a detailed concrete form, so movement has no effect. As we fur-
ther develop the application, resolutions of these issues and others will emerge.
 
Search WWH ::




Custom Search