Java Reference
In-Depth Information
Consider the definition of the classification of fireworks. In the United States, federal law
defines two primary classifications, with each type of firework classified as either
a consumer or a display type of firework. A display firework, any type of firework that is not
a consumer firework, may be used only by licensed operators. In federal law, the consumer
classification defines fireworks that states may allow ordinary citizens to purchase and to use.
The consumer class is surprisingly large at the federal level, including rockets and aerial
shells. State laws specify which consumer fireworks, if any, are legal to purchase and to
operate.
Developers at Oozinoz use Classification constants to track whether a firework is
federally mandated to be sold only to licensed operators (see Figure 2.2).
Figure 2.2. A Firework object has a classification that reflects whether Oozinoz can sell
the firework to unlicensed operators.
The names of the Firework_1 and the Classification_1 classes each end with an
underscore and a version number because we will soon refactor their code into new versions.
When you refactor code, you should not normally include versioning information in class
names. Rather, you should use a configuration management system to keep track of versions
of your code. However, two versions of the Classification class appear simultaneously
in this topic, and the naming scheme helps to differentiate these versions.
The Classification_1 class sets up two constants that define a firework's classification:
package com.oozinoz.fireworks;
public class Classification_1
{
public static final Classification_1 CONSUMER =
new Classification_1();
public static final Classification_1 DISPLAY =
new Classification_1();
private Classification_1()
{
}
}
A typical method that checks the classification constants looks like this:
Search WWH ::




Custom Search