|
5. Hints to improve designSome hints for removing cyclic dependencies can be extracted from the analysis Classycle performs. As explained in Chapter 3.2 Classycle calculates for each class/package in the cycle its potential to fragmentize the cycle into smaller subcycles when it is removed from the cycle. Classycle lists the maximum fragment size for each class. The best fragmenters are those classes/packages in the cycle leading to the smallest maximum fragment size. The optimum (best fragment size = 1) is reached when a vertex is found whose removal would turn the cycle into a complete acyclic graph.4.1 Resolving Class CyclesOf course removing a class does not make sense from the point of view of a Java application because it needs this class. Fortunately, the same effect can be obtained by replacing the vertex by two vertices in the following way:A general and widely used recipes for splitting of a class A into A' and A'' is the introduction of an interface: Here A' is an interface which is implemented by A''. Sometimes it is possible to split A into two independent concrete classes A' and A''. But this is a rare case. 4.2 Resolving Package CyclesPackage cycles are cured in three or four steps:
|
(C) 2003-2008 Franz-Josef Elmer. All rights reserved. Last modified: 11/21/2004 |