Java Reference
In-Depth Information
12.4 Case Study: Printing an Invoice
In this chapter, we discuss a five-part development process that is particularly well
suited for beginning programmers:
1.
Gather requirements.
2.
Use CRC cards to find classes, responsibilities, and collaborators.
3.
Use UML diagrams to record class relationships.
4.
Use javadoc to document method behavior.
5.
Implement your program.
There isn't a lot of notation to learn. The class diagrams are simple to draw. The
deliverables of the design phase are obviously useful for the implementation phaseȌ
you simply take the source files and start adding the method code. Of course, as your
projects get more complex, you will want to learn more about formal design methods.
There are many techniques to describe object scenarios, call sequencing, the
large-scale structure of programs, and so on, that are very beneficial even for
relatively simple projects. The Unified Modeling Language User Guide [ 1 ] gives a
good overview of these techniques.
In this section, we will walk through the object-oriented design technique with a very
simple example. In this case, the methodology may feel overblown, but it is a good
introduction to the mechanics of each step. You will then be better prepared for the
more complex example that follows.
12.4.1 Requirements
The task of this program is to print out an invoice. An invoice describes the charges
for a set of products in certain quantities. (We omit complexities such as dates,
taxes, and invoice and customer numbers.) The program simply prints the billing
address, all line items, and the amount due. Each line item contains the description
and unit price of a product, the quantity ordered, and the total price.
544
Search WWH ::




Custom Search