Page 302 - AP Computer Science A, 7th edition
P. 302

implemented and tested before being incorporated into the overall project. Typically, these are the basic objects of the program, like StockItem, Card, and BingoCard. U nrelat ed c las s es in a programming project can be implemented by different programmers.
Note that a class can be tested using a dummy Tester class that will be discarded when the methods of the class are working. Constructors, then methods, should be added, and tested, one at a time. A driver class that contains a main method can be used to test the program as you go. The purpose of the driver is to test the class fully before incorporating it as an object in a new class.
When each of the independent classes is working, classes that depend on just one other class are implemented and tested, and so on. This may lead to a working, bare bones version of the project. New features and enhancements can be added later.
Design flaws can be corrected at each stage of development. Remember, a design is never set in stone: It simply guides the implementation.
TOP-DOWN DEVELOPMENT
In a top-down design, the programmer starts with an overview of the program, selecting the highest-level controlling object and the tasks needed. During development of the program, subsidiary classes may be added to simplify existing classes.
Implementing Methods
PROCEDURAL ABSTRACTION
A good programmer avoids chunks of repeated code wherever possible. To this end, if several methods in a class require the same task, like a search or a swap, you should use helper methods. The reduce method in the Rational class is an example of such a


























































































   300   301   302   303   304