Dependency Finder Tutorial for Dependency Finder by Jean
Dependency Finder Tutorial for Dependency Finder by Jean Tessier, March 30, 2004 1
Dependency Finder What are dependencies? Functioning of A requires the presence of B. A source dependent UML: outbound inbound B target dependable C 1 C 2 P 1 P 2 2
Dependency Finder Why Should I Care? • Improve compilation time – Smaller parts are easier on the compiler • Verify encapsulation – Validate design assumptions • Indicator of complexity • Assist with maintenance – Impact of change 3
Dependency Finder Where Do They Come From? • Class-to-Class P 1 P 2 C 1 C 2 F 1 F 2 – Class inheritance via extends keyword – Interface realization via implements keyword – From fields and methods of the class 4
Dependency Finder Where Do They Come From? • Feature-to-Class P 1 P 2 C 1 C 2 F 1 F 2 – Field type – Method parameter type – Exception types in throws clause – Local variable type 5
Dependency Finder Where Do They Come From? • Feature-to-Feature P 1 P 2 C 1 C 2 F 1 F 2 – Field access – Method call – Method cannot depend on itself, as in recursive calls 6
Dependency Finder No Dependency on Self P C F • Does not add information • Compile time – Class is unit of compilation • Runtime – Class is unit of loading • Maintenance – Already editing class or feature 7
Dependency Finder Explicit Dependencies • Source code P 1 P 2 C 1 C 2 F 1 F 2 – static final constants – Needed for compilation • Compiled code – Fully qualified names – No 3 rd party JARs – Needed for runtime 8
Dependency Finder Implicit Dependencies P 1 P 2 C 1 C 2 F 1 F 2 • Derived from explicit • Minimize – Reduce space – Augment time • Maximize – Augment space – Reduce time 9
Dependency Finder Implicit Dependencies classes of a package features of a class self P P P C C C 1 C 2 F 1 F 2 F 10
Dependency Finder Package Instability (from Robert C. Martin) Ca Number of classes outside the package that depend upon classes inside the package. Ce Number of classes outside the package that classes inside the package depend upon. I = Ce Ca + Ce • High Ce or low Ca means hard to change • If Ca and Ce are 0, then I = 0 • Depend on packages with lower I than you 11
Dependency Finder A vs I Graph (from Robert C. Martin) 1 uselessness A + I– A 1 = 0 pain 0 I • Depend on abstract packages • Concrete packages should have no dependents 1 12
Dependency Finder Are Dependencies Transitive? A B ? ? C ? • It depends! • Case-by-case, not automatic • Is part of B that A depends on impacted by changes in C? 13
Dependency Finder Transitive Closure callers dependents dependencies 14
Dependency Finder Transitive Closure + 2 1 0 0 1 2 + 15
Dependency Finder Package-to-Package Example Default configuration Complete package-level graph 16
Dependency Finder Package-to-Package Example Excluding /java/ Don’t list dependencies on anything with java 17
Dependency Finder Why Do I See java <-- jeantessier? P 1 Scope Factory P 2 C 1 C 2 P 1 P 2 Filter Factory F 1 F 2 C 1 C 2 P 1 P 2 F 1 F 2 C 1 C 2 F 1 F 2 original copy 18
Dependency Finder Package-to-Package Example Excluding /^java/ Don’t list dependencies on java. * 19
Dependency Finder Package-to-Package Example Including /^com. jean/ Only list dependencies with com. jean* 20
Dependency Finder Package-to-Package Example Including /^com. jean/, /^test/ Only list with com. jean* and test. * 21
Dependency Finder Package-to-Package Example Excluding /^java/ Don’t list packages in java. * 22
Dependency Finder Package-to-Package Example Including /com. jean/, /^test/ Only list test. * and com. jean* 23
Dependency Finder Feature-to-Feature Example Including /Node. Accept/ Calls to *Node. Accept() methods 24
Dependency Finder Feature-to-Feature Example Including /Node. Accept(/ Calls to *Node. Accept() methods, less output 25
Dependency Finder Feature-to-Feature Example Including /(Node). 1(/ Calls to constructors of Node 26
Dependency Finder Feature-to-Feature Example Including /(w*Node). 1(/ Calls to constructors of classes ending in Node 27
Dependency Finder Feature-to-Feature Example Including /Node. Factory/ Calls to methods of Node. Factory 28
Dependency Finder Transitive Closure Example Shows Accept*() methods 29
Dependency Finder Transitive Closure Example Direct callers of Accept*() 30
Dependency Finder Transitive Closure Example Second degree callers of Accept*() 31
Dependency Finder Transitive Closure Example Everything reachable from Accept*() 32
Dependency Finder Perl Regular Expressions • [A-Z] Capitals • w Alphanumeric [A-Za-z 0 -9_] • W Non-alpha [^A-Za-z 0 -9_] At least one alphanumeric • s Space, including tab and eol • s* Zero or more white space • . ‘. ’ as opposed to any character • w+ 33
Dependency Finder The End depfind. sourceforge. net 34
- Slides: 34