Linking Everything Together


Developers often get used to feeding a function with all the data it needs—and (just as often) apply this same thinking to classes. These programmers create a class and connect it (via associations) to all other classes that have any data the first class might need in one of its operations. For instance, an AutoPolicy class is associated with Claim, MedicalCoverage, LiabilityCoverage, ComprehensiveCoverage, Auto, Agent, Premium, Payment, and Person classes. The developer forgets that one class (AutoPolicy) can ask another class (Premium) for information about yet another class—the dollar value from the Payment class—without having to associate the AutoPolicy class directly to the Payment class.

 Warning   Class diagrams—where most classes connect to most other classes—can be the royal road to maintenance nightmares. Any time you associate one class to another class, you have a dependency between those classes. If you change one class, the other may change too. The more associations between classes, the more dependencies you must worry about.

 Tip   When you see class diagrams with every class connected to every other class, remove some of those associations. You should find out which associations are really necessary and which associations exist simply to get data from one class to another class.




UML 2 for Dummies
UML 2 For Dummies
ISBN: 0764526146
EAN: 2147483647
Year: 2006
Pages: 193

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net