Java Reference
In-Depth Information
To visualize relationships, such as dependence between classes, programmers draw
class diagrams. In this topic, we use the UML (ȒUnified Modeling Languageȓ)
notation for objects and classes. UML is a notation for object-oriented analysis and
design invented by Grady Booch, Ivar Jacobson, and James Rumbaugh, three leading
researchers in object-oriented software development. The UML notation distinguishes
between object diagrams and class diagrams. In an object diagram the class names
are underlined; in a class diagram the class names are not underlined. In a class
diagram, you denote dependency by a dashed line with a -shaped open arrow tip that
points to the dependent class. Figure 1 shows a class diagram indicating that the
CashRegister class depends on the Coin class.
Note that the Coin class does not depend on the CashRegister class. Coins have
no idea that they are being collected in cash registers, and they can carry out their
work without ever calling any method in the CashRegister class.
If many classes of a program depend on each other, then we say that the coupling
between classes is high. Conversely, if there are few dependencies between classes,
then we say that the coupling is low (see Figure 2 ).
Figure 2
High and Low Coupling Between Classes
339
340
Why does coupling matter? If the Coin class changes in the next release of the
program, all the classes that depend on it may be affected. If the change is drastic, the
coupled classes must all be updated. Furthermore, if we would like to use a class in
Search WWH ::




Custom Search