forked from clarkware/jdepend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JDepend.html
executable file
·1605 lines (1481 loc) · 42.5 KB
/
JDepend.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>JDepend</title>
<meta name="keywords" content="JDepend, Java package dependency,
Java metrics, Martin Metrics"/>
<meta name="description" content="A Java package dependency analyzer
that generates design quality metrics."/>
<style type="text/css">
<!--
body {
font-family: Lucida, Verdana, Arial, Geneva, Helvetica, sans-serif;
margin-left: 2em;
margin-right: 2em;
margin-top: 2em;
margin-bottom: 2em;
}
a {
color: #000090;
text-decoration: none;
}
a:hover {
color: red;
text-decoration: underline;
}
div#title {
color: white;
background: #000090;
font-size: 150%;
font-weight: bold;
text-align: center;
padding-top: 0.125em;
padding-bottom: 0.125em;
}
div#summary {
margin-left: 4em;
margin-right: 4em;
}
div.header {
color: #000090;
background: #EDEDED;
font-weight: bold;
border-top: 1px solid #000090;
border-left: 1px solid #000090;
padding-top: .25em;
padding-bottom: .25em;
padding-left: 0.5em;
margin-top: 1.5em;
margin-bottom: 0;
}
div.code-header {
color: white;
font-weight: bold;
text-align: center;
background: #000090;
padding-top: .25em;
padding-bottom: .25em;
margin-left: 5em;
margin-right: 5em;
margin-left: 5em;
margin-right: 5em;
}
div.code {
background: #EDEDED;
border-top: 1px solid #000090;
border-bottom: 1px solid #000090;
border-right: 1px solid #000090;
border-left: 1px solid #000090;
padding-left: 2em;
margin-top: 0;
margin-bottom: 2em;
margin-left: 5em;
margin-right: 5em;
}
div#copyright {
color: #AAAAAA;
font-size: 0.8em;
text-align: center;
margin-top: 3em;
}
-->
</style>
</head>
<body>
<!--
Title
-->
<div id="title">
JDepend
</div>
<!--
Summary
-->
<div id="summary">
<p>
<b><u>Summary</u></b>
</p>
<p>
JDepend traverses Java class file directories and generates design
quality metrics for each Java package. JDepend allows you to
automatically measure the quality of a design in terms of its
extensibility, reusability, and maintainability to manage package
dependencies effectively.
</p>
</div>
<!--
Table of Contents
-->
<div class="header">
Table of Contents
</div>
<ul>
<li><a href="#overview">Overview</a></li>
<li><a href="#uses">Why Use JDepend?</a></li>
<li><a href="#download">Downloading JDepend</a></li>
<li><a href="#installation">Installing JDepend</a></li>
<li><a href="#building">Building and Testing JDepend</a></li>
<li><a href="#howtouse">Running JDepend</a></li>
<li><a href="#graphical">Graphical UI Navigation</a></li>
<li><a href="#cycles">Interpreting Dependency Cycles</a></li>
<li><a href="#customize">Customizing JDepend</a></li>
<li><a href="#junit">Using JDepend With JUnit</a></li>
<li><a href="#fitnesse">Using JDepend With FitNesse</a></li>
<li><a href="#ant">Using JDepend With Ant</a></li>
<li><a href="#limitations">Limitations</a></li>
<li><a href="#donate">Donate</a></li>
<li><a href="#license">License</a></li>
<li><a href="#credits">Acknowledgments</a></li>
<li><a href="#resources">Resources</a></li>
</ul>
<!--
Overview
-->
<div class="header">
<a name="overview"></a>
Overview
</div>
<p>
JDepend traverses Java class file directories and generates design
quality metrics for each Java package, including:
</p>
<ul>
<li><b>Number of Classes and Interfaces</b>
<p>
The number of concrete and abstract classes (and interfaces) in the
package is an indicator of the extensibility of the package.
</p>
</li>
<li><b>Afferent Couplings (Ca)</b>
<p>
The number of other packages that depend upon classes within
the package is an indicator of the package's responsibility.
</p>
</li>
<li><b>Efferent Couplings (Ce)</b>
<p>
The number of other packages that the classes in the package depend
upon is an indicator of the package's independence.
</p>
</li>
<li><b>Abstractness (A)</b>
<p>
The ratio of the number of abstract classes (and interfaces)
in the analyzed package to the total number of classes in
the analyzed package.
</p>
<p>
The range for this metric is 0 to 1, with A=0 indicating a
completely concrete package and A=1 indicating a completely
abstract package.
</p>
</li>
<li><b>Instability (I)</b>
<p>
The ratio of efferent coupling (Ce) to total coupling
(Ce + Ca) such that I = Ce / (Ce + Ca). This metric is
an indicator of the package's resilience to change.
</p>
<p>
The range for this metric is 0 to 1, with I=0 indicating
a completely stable package and I=1 indicating a completely
instable package.
</p>
</li>
<li><b>Distance from the Main Sequence (D)</b>
<p>
The perpendicular distance of a package from the idealized
line A + I = 1. This metric is an indicator of the package's
balance between abstractness and stability.
</p>
<p>
A package squarely on the main sequence is optimally balanced
with respect to its abstractness and stability. Ideal packages
are either completely abstract and stable (x=0, y=1) or completely
concrete and instable (x=1, y=0).
</p>
<p>
The range for this metric is 0 to 1, with D=0 indicating
a package that is coincident with the main sequence and
D=1 indicating a package that is as far from the main sequence
as possible.
</p>
</li>
<li><b>Package Dependency Cycles</b>
<p>
Package dependency cycles are reported along with the hierarchical
paths of packages participating in package dependency cycles.
</p>
</li>
</ul>
<!--
Uses
-->
<div class="header">
<a name="uses"></a>
Why Use JDepend?
</div>
<p>
Before using JDepend, it is important to understand that
"good" design quality metrics are not necessarily indicative
of good designs. Likewise, "bad" design quality metrics are
not necessarily indicative of bad designs. The design quality metrics
produced by JDepend should not be used as yard sticks by which all
designs are measured.
</p>
<p>
The design quality metrics produced by JDepend are intended to be used
by designers to measure the designs they create, understand those
designs, and automatically check that the designs exhibit expected
qualities while undergoing continuous refactoring. Refactoring will
undoubtedly lead to some adjustment of these metrics as the shape of
the design changes.
</p>
<p>
<b>Measure Design Quality</b>
</p>
<p>
The quality of a design can be measured in part by quantifying its
degrees of extensibility, reusability, and maintainability. These
qualities are all influenced by the inter-package dependencies of the
design. Designs are more extensible when they are independent of
implementation details, allowing them to adapt to new implementations
without internal modification or breaking their existing contracts.
This same independence tends to increase the reuse potential of
portions of the design. Independent portions of the design containing
high-level abstractions can be extracted from portions containing
implementation details.
</p>
<p>
The maintainability of a design is improved when changes can easily be
made without propagating to other parts of the system. JDepend allows
you to automatically measure the quality of a design in terms of its
extensibility, reusability, and maintainability to effectively manage
and control package dependencies.
</p>
<p>
<b>Invert Dependencies</b>
</p>
<p>
The goal of using JDepend is to ultimately invert package dependencies
such that low-abstraction packages depend upon high-abstraction
packages. This inversion of dependencies allows the high-abstraction
packages to be reused independently while being extensible to an open
set of implementations. In general, dependencies upon stable packages
are desirable, while dependencies upon instable packages are
undesirable. JDepend allows dependencies to be iteratively examined
and refactored as an integral part of software design and development.
</p>
<p>
<b>Foster Parallel, Extreme Programming</b>
</p>
<p>
Packages that are stable should be the centerpieces of a loosely
coupled application so the speed of the development team is not
adversely affected by the propagation of software changes. Stable
packages form design-by-contract facades to other subsystems, allowing
teams to develop in parallel at an extreme pace. Moreover, by
measuring the software design quality, the overall impact of proposed
software changes can be accurately estimated. JDepend allows teams to
identify and use desirable dependencies in the system and avoid those
dependencies that cause changes to ripple throughout the system.
</p>
<p>
<b>Isolate Third-Party Package Dependencies</b>
</p>
<p>
Third-party package dependencies can be easily identified and isolated
by examining the afferent couplings to those packages. Once the
dependency on these third-party packages has been measured with
JDepend, the dependency can be managed by effectively designing
abstract and stable packages that encapsulate the third-party package
implementation details.
</p>
<p>
<b>Package Release Modules</b>
</p>
<p>
Packages that are cohesive and independent can be released as
autonomous modules with their own release schedules and version
numbers. Single packages, or groups of related packages collaborating
in a framework, that are candidates for independent release can be
harvested by evaluating their design quality metrics using JDepend.
</p>
<p>
<b>Identify Package Dependency Cycles</b>
</p>
<p>
Packages participating in a package dependency cycle are in a deadly
embrace with respect to reusability and their release cycle. Package
dependency cycles can be easily identified by reviewing the textual
reports of dependency cycles. Once these dependency cycles have been
identified with JDepend, they can be broken by employing various
object-oriented techniques.
</p>
<!--
Download
-->
<div class="header">
<a name="download"></a>
Downloading JDepend
</div>
<p>
<a href="https://github.com/clarkware/jdepend/releases/download/2.10/jdepend-2.10.zip">JDepend 2.10</a> is the latest major version release. It includes all the
minor version changes.
</p>
<p>
The distribution contains a JAR file, source code, sample application,
API documentation, and this document.
</p>
<!--
Installation
-->
<div class="header">
<a name="installation"></a>
Installing JDepend
</div>
<p>
<b>Windows</b>
</p>
<p>
To install JDepend, follow these steps:
</p>
<ol>
<li>
<p>
Unzip the <code>jdepend-<version>.zip</code> distribution
file to a directory referred to as <code>%JDEPEND_HOME%</code>.
</p>
</li>
<li>
<p>
Add JDepend to the classpath:
</p>
<p>
<code>set CLASSPATH=%CLASSPATH%;%JDEPEND_HOME%\lib\jdepend-<version>.jar</code>
</p>
</li>
</ol>
<p>
<b>Unix (bash)</b>
</p>
<p>
To install JDepend, follow these steps:
</p>
<ol>
<li>
<p>
Unzip the <code>jdepend-<version>.zip</code> distribution
file to a directory referred to as <code>$JDEPEND_HOME</code>.
</p>
</li>
<li>
<p>
Change file permissions:
</p>
<p>
<code>chmod -R a+x $JDEPEND_HOME</code>
</p>
</li>
<li>Add JDepend to the classpath:
<p>
<code>export CLASSPATH=$CLASSPATH:$JDEPEND_HOME/lib/jdepend-<version>.jar</code>
</p>
</li>
</ol>
<!--
Building
-->
<div class="header">
<a name="building"></a>
Building and Testing JDepend
</div>
<p>
The JDepend distribution includes the pre-built classes in the
<code>$JDEPEND_HOME/lib/jdepend-<version>.jar</code> file.
</p>
<p>
<b>Building</b>
</p>
<p>
An <a href="http://jakarta.apache.org/ant" target="_parent">Ant</a>
build file is included in <code>$JDEPEND_HOME/build.xml</code> to
build the <code>$JDEPEND_HOME/dist/jdepend-<version>.jar</code>
file from the included source code.
</p>
<p>
To build JDepend, use:
</p>
<div>
<blockquote>
<pre>
cd $JDEPEND_HOME
ant jar
</pre>
</blockquote>
</div>
<p>
<b>Testing</b>
</p>
<p>
The JDepend distribution includes
<a href="http://www.junit.org" target="_parent">JUnit</a>
test cases to validate the integrity of JDepend.
</p>
<p>
To test JDepend, use:
</p>
<div>
<blockquote>
<pre>
cd $JDEPEND_HOME
ant test
</pre>
</blockquote>
</div>
<!--
How To Use
-->
<div class="header">
<a name="howtouse"></a>
Running JDepend
</div>
<p>
JDepend provides a graphical, textual, and XML user interface to
visualize Java package metrics, dependencies, and cycles.
</p>
<p>
<b>Graphical UI</b>
</p>
<p>
The graphical user interface displays a hierarchical tree for both the
afferent and efferent couplings of each analyzed Java package.
</p>
<p>
To run JDepend with the graphical user interface, use the following syntax:
</p>
<div>
<blockquote>
<pre>
java jdepend.swingui.JDepend [-components <components>] <directory> [directory2 [directory 3] ...]
</pre>
</blockquote>
</div>
<p>
For example, to analyze all the Java class files in the
<code>$JDEPEND_HOME/build</code> directory, use:
</p>
<div>
<blockquote>
<pre>
java jdepend.swingui.JDepend $JDEPEND_HOME/build
</pre>
</blockquote>
</div>
<p>
<b>Textual UI</b>
</p>
<p>
The textual user interface displays detailed metrics, dependencies,
and cycles for each analyzed Java package. For the convenience of
importing these metrics into other applications, the summary section
contains comma-separated metrics for each Java package.
Alternatively, the XML user interface can be used for easier
integration with other tools.
</p>
<p>
To run JDepend with the textual user interface, use the following
syntax:
</p>
<div>
<blockquote>
<pre>
java jdepend.textui.JDepend [-components <components>] [-file <output file>] <directory> [directory2 [directory 3] ...]
</pre>
</blockquote>
</div>
<p>
For example, to analyze all the Java class files in the
<code>$JDEPEND_HOME/build</code> directory, use:
</p>
<div>
<blockquote>
<pre>
java jdepend.textui.JDepend $JDEPEND_HOME/build
</pre>
</blockquote>
</div>
<p>
Alternatively, the text report can be written to file using:
</p>
<div>
<blockquote>
<pre>
java jdepend.textui.JDepend -file report.txt $JDEPEND_HOME/build
</pre>
</blockquote>
</div>
<p>
<a href="jdepend-text.out" target="_parent">Example output</a> from the
textual UI shows the analysis of the sample application, an example
electronic payment framework. The relevant source for the sample
application is distributed in
<code>$JDEPEND_HOME/sample</code>.
</p>
<p>
<b>XML UI</b>
</p>
<p>
The XML user interface displays detailed metrics, dependencies, and
cycles for each analyzed Java package in an XML format for easier
integration with other tools.
</p>
<p>
To run JDepend with the XML user interface, use the following syntax:
</p>
<div>
<blockquote>
<pre>
java jdepend.xmlui.JDepend [-components <components>] [-file <output file>] <directory> [directory2 [directory 3] ...]
</pre>
</blockquote>
</div>
<p>
For example, to analyze all the Java class files in the
<code>$JDEPEND_HOME/build</code> directory, use:
</p>
<div>
<blockquote>
<pre>
java jdepend.xmlui.JDepend $JDEPEND_HOME/build
</pre>
</blockquote>
</div>
<p>
Alternatively, the XML report can be written to file using:
</p>
<div>
<blockquote>
<pre>
java jdepend.xmlui.JDepend -file report.xml $JDEPEND_HOME/build
</pre>
</blockquote>
</div>
<p>
<a href="jdepend-xml.out" target="_parent">Example output</a> from the
XML UI shows the analysis of the sample application, an example
electronic payment framework. The relevant source for the sample
application is distributed in
<code>$JDEPEND_HOME/sample</code>.
</p>
<p>
You can then transform the XML format into a format of your liking.
For example, David Bock contributed an XSL stylesheet that transforms
the JDepend XML output into a <a
href="http://www.research.att.com/sw/tools/graphviz/"
target="_parent">Graphviz</a> dot file format. David's stylesheet is
distributed with JDepend in the <code>contrib/jdepend2dot.xsl</code>
file.
</p>
<p>
To create a sample Graphviz file, use:
</p>
<div>
<blockquote>
<pre>
ant jdepend-to-graphviz
</pre>
</blockquote>
</div>
<p>
This will create a <code>docs/jdepend-report.dot</code> file. If
you have Graphviz installed, you can then convert that .dot file
into a .png file using:
</p>
<div>
<blockquote>
<pre>
dot -Tpng -o jdepend.png jdepend.dot
</pre>
</blockquote>
</div>
<!--
Graphical UI Navigation
-->
<div class="header">
<a name="graphical"></a>
Graphical UI Navigation
</div>
<p>
The graphical user interface displays the afferent and efferent
couplings of each analyzed Java package, presented in the familiar
Java Swing tree structure.
</p>
<p>
Figure 1 shows the analysis of the sample application, an example
electronic payment framework. The relevant source for the sample
application is distributed in <code>$JDEPEND_HOME/sample</code>.
</p>
<p>
<a href="images/figure1b.jpg" target="_parent">
<img src="images/figure1a.jpg" alt="Figure 1"/>
</a>
<br/>
Figure 1 (Click to view full-scale)
</p>
<p>
The root of each tree displays a branch for each analyzed Java
package, annotated with the following metrics:
</p>
<ul>
<li>
<b>CC</b> - Concrete Class Count
</li>
<li>
<b>AC</b> - Abstract Class (and Interface) Count
</li>
<li>
<b>Ca</b> - Afferent Couplings (Ca)
</li>
<li>
<b>Ce</b> - Efferent Couplings (Ce)
</li>
<li>
<b>A</b> - Abstractness (0-1)
</li>
<li>
<b>I</b> - Instability (0-1)
</li>
<li>
<b>D</b> - Distance from the Main Sequence (0-1)
</li>
<li>
<b>V</b> - Volatility (0-1)
</li>
<li>
<b>Cyclic</b> - If the package contains a dependency cycle
</li>
</ul>
<p>
For organizational purposes, package metrics are only displayed at the
root of each tree. For convenience, selecting any node of the tree
displays the currently selected package's metrics in the status bar.
</p>
<p>
<b>Efferent Couplings</b>
</p>
<p>
The top tree displays the efferent couplings of each analyzed Java
package. Branches of the tree can be opened up to explore packages
that the currently selected package depends upon (Figure 2).
</p>
<p>
<a href="images/figure2b.jpg" target="_parent">
<img src="images/figure2b.jpg" alt="Figure 2"/>
</a>
<br/>
Figure 2 (Click to view full-scale)
</p>
<p>
For the <code>epayment.adapters</code> package, we see that it depends
upon 4 other packages:
the <code>com.abc.epayment</code>, <code>com.xyz.epayment</code>,
<code>epayment.framework</code>, and the <code>epayment.response</code>
packages. Furthermore, it's completely concrete (A=0) and completely
instable (I=1). This balance earns it a spot squarely on the main
sequence (D=0). We can conclude from these metrics that dependencies on
this package are undesirable because it's both dependent and irresponsible.
It's sensitive to modifications made to any of it's efferent couplings and
not accountable to any other package. Therefore, it's important that other
packages in the system not become dependent on this package, as they'll in turn
become fragile by any modifications made to the details of the
<code>epayment.adapters</code> package and its dependencies. As a concrete
package, it's not capable of being extended without being modified.
</p>
<p>
For the <code>epayment.framework</code> package, we see that it does
not depend on any other packages in the application (Ce=0). However,
it is responsible to every other package (Ca=5) while exhibiting a
high degree of abstractness (A=0.83) and stability (I=0). While not
completely balanced, this package is very near the main sequence
(D=0.17). We can conclude from these metrics that dependencies on
this package are desirable because it's both independent and
responsible. It's abstractness also indicates that it's capable of
being extended to accommodate new implementations without being
modified.
</p>
<p>
Packages that were imported, but not analyzed, are not shown in the
efferent dependency tree. Third-party software packages that weren't
analyzed, for example, will not be shown in the efferent tree, as
their efferent dependencies are not available.
</p>
<p>
<b>Afferent Couplings</b>
</p>
<p>
The bottom tree displays the afferent couplings of each analyzed Java
package. Branches of the tree can be opened up to explore packages
that use the currently selected package (Figure 3).
</p>
<p>
<a href="images/figure3b.jpg" target="_parent">
<img src="images/figure3b.jpg" alt="Figure 3"/>
</a>
<br/>
Figure 3 (Click to view full-scale)
</p>
<p>
For the <code>epayment.adapters</code> package, we see that it is not
used by any other package in the application. This confirms our
observations of the efferent dependency tree.
</p>
<p>
For the <code>epayment.framework</code> package, we see that it's used
by all the other user-defined packages in the framework. However, it
does not have any efferent couplings (Ce=0) and exhibits a high degree
of abstractness (A=0.83) and stability (I=0). This is a requirement
of a software framework - we want it to be heavily used, thereby
making it very responsible to its clients, yet be highly abstract to
allow extensibility without modification.
</p>
<p>
For the <code>com.abc.epayment</code> package, a third-party software
package, we see that it's used by the <code>epayment.adapters</code>
package. There are no metrics displayed for this package however, as
it's a third-party package that was not analyzed by JDepend. It was
imported by a user-defined package (<code>epayment.adapters</code>),
so it is shown in the afferent dependency tree.
</p>
<p>
Using the afferent dependency tree, it's easy to identify which
user-defined packages are dependent upon third-party software
packages.
</p>
<!--
Interpreting Dependency Cycles
-->
<div class="header">
<a name="cycles"></a>
Interpreting Dependency Cycles
</div>
<p>
Package dependency cycles are best observed using the textual or XML
user interface. In general, all packages dependencies that intersect
a dependency cycle are reported. This includes packages directly
participating in a cycle and packages that depend on packages directly
participating in a cycle.
</p>
<p>
The intent is to identify sets of packages that must be reused and
released together. To break reported cycles, focus on those packages
directly participating in a cycle.
</p>
<p>
Here's an example of a two-package cycle, as reported by the textual UI:
</p>
<div>
<blockquote>
<pre>
com.xyz.ejb
|
| com.xyz.servlet
|-> com.xyz.ejb
</pre>
</blockquote>
</div>
<p>
This indicates that the <code>com.xyz.ejb</code> package depends on
the
<code>com.xyz.servlet</code> package, which in turn depends on the
<code>com.xyz.ejb</code> package. These two package must be released and
reused together.
</p>
<p>
Here's an example of a package that depends on the two-package cycle
described above, as reported by the textual UI:
</p>
<div>
<blockquote>
<pre>
com.xyz.client
|
|-> com.xyz.ejb
| com.xyz.servlet
|-> com.xyz.ejb
</pre>
</blockquote>
</div>
<p>
This indicates that the <code>com.xyz.client</code> package depends on
the <code>com.xyz.ejb</code> package, which in turn forms a cyclic
dependency with the <code>com.xyz.servlet</code> package.
The <code>com.xyz.client</code> package itself isn't part of the
cycle, but since it depends on a package in the cycle, it can't be
reused/released without it.
</p>
<!--
Customizing
-->
<div class="header">
<a name="customize"></a>
Customizing JDepend
</div>
<p>
JDepend can be customized by using command-line options and/or by
creating a <code>jdepend.properties</code> file in the user's home
directory or any directory in the classpath.
</p>
<p>
<b>Components</b>
</p>
<p>
JDepend can calculate metrics and dependencies for components:
packages that contain one or more sub-packages.
</p>
<p>
For example, given the following package hierarchy:
</p>
<div>
<blockquote>
<pre>
com.xyz.package_a.subpackage_a
com.xyz.package_a.subpackage_b
com.xyz.package_a.subpackage_c
com.xyz.package_b.subpackage_a
com.xyz.package_b.subpackage_b
</pre>
</blockquote>
</div>
<p>
Assume you want to collect metrics and dependencies for the
<code>com.xyz.package_a</code> and <code>com.xyz.package_b</code>
packages, but not for any of their contained packages. For example,
if there is a dependency from <code>com.xyz.package_a.subpackage_a</code>
to <code>com.xyz.package_b.subpackage_b</code>, then you want it
to be reported as a dependency from <code>com.xyz.package_a</code>
to <code>com.xyz.package_b.subpackage_b</code>.
</p>
<p>
To do that, use the <code>-components</code> command-line argument:
</p>
<div>
<blockquote>
<pre>
java jdepend.textui.JDepend -components com.xyx.package_a,com.xyz.package_b /path/to/classes
</pre>
</blockquote>
</div>
<p>
Note that if component packages are named using the
<code>-components</code> option, then no other packages
are reported.
</p>
<p>
<b>Package Filters</b>
</p>
<p>
JDepend will ignore all package names specified as values to the
<code>ignore</code> property name prefix in the
<code>jdepend.properties</code> file. By default, no packages are filtered.
</p>
<p>
The following example <code>jdepend.properties</code> file will ignore
all package names prefixed by <code>java</code>, <code>javax</code>,
<code>sun</code>, <code>com.sun</code>, and the package
<code>com.xyz.tests</code>:
</p>
<div>
<blockquote>
<pre>
ignore.java=java.*,javax.*
ignore.sun=sun.*,com.sun.*
ignore.tests=com.xyz.tests
</pre>
</blockquote>
</div>
<p>
Packages can also be filtered programmatically by creating a
<code>PackageFilter</code> instance defining the filters and
then passing it to the <code>JDepend</code> constructor.
</p>
<p>
The following example will ignore all package names prefixed by
<code>java</code> and <code>javax</code>, in addition to any
package filters specified in an existing
<code>jdepend.properties</code> file:
</p>
<div>
<blockquote>
<pre>
PackageFilter filter = new PackageFilter();
filter.addPackage("java.*");
filter.addPackage("javax.*");
JDepend jdepend = new JDepend(filter);
</pre>
</blockquote>
</div>
<p>
The following example will ignore only the package names prefixed
by <code>java</code> and <code>javax</code>, regardless of any package
filters specified in an existing
<code>jdepend.properties</code> file:
</p>
<div>
<blockquote>
<pre>
Collection filters = new ArrayList();
filters.add("java.*");
filters.add("javax.*");
PackageFilter filter = new PackageFilter(filters);
JDepend jdepend = new JDepend(filter);
</pre>
</blockquote>
</div>
<p>
<b>Volatility</b>
</p>
<p>
Packages that are not expected to change can be specifically
configured with a volatility (V) value in the
<code>jdepend.properties</code> file.
V can either be 0 or 1. If V=0, meaning the package is not at
all subject to change, then the package will automatically fall
directly on the main sequence (D=0). If V=1, meaning that the
package is subject to change, then the distance from the main