More than Just Lines on a Map: Best Practices for U.S Bike Routes
Dependency Finder Tutorial
1. Dependency Finder
Tutorial
for Dependency Finder
by Jean Tessier,
March 30, 2004
1
2. Dependency Finder
What are dependencies?
Functioning of A requires the presence of B.
A B
source outbound inbound target
dependent dependable
UML: C1 C2
P1 P2
2
3. 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
4. Dependency Finder
Where Do They Come From?
• Class-to-Class
P1 P2
– Class inheritance via
extends keyword
C1 C2
– Interface realization via
F1 F2 implements keyword
– From fields and methods
of the class
4
5. Dependency Finder
Where Do They Come From?
• Feature-to-Class
P1 P2
– Field type
C1 C2 – Method parameter type
– Exception types in
F1 F2 throws clause
– Local variable type
5
6. Dependency Finder
Where Do They Come From?
• Feature-to-Feature
P1 P2
– Field access
C1 C2 – Method call
– Method cannot depend on
F1 F2 itself, as in recursive calls
6
7. Dependency Finder
No Dependency on Self
• Does not add information
P • Compile time
– Class is unit of compilation
C
• Runtime
F – Class is unit of loading
• Maintenance
– Already editing class or
feature
7
8. Dependency Finder
Explicit Dependencies
• Source code
P1 P2 – static final constants
C1 C2 – Needed for compilation
• Compiled code
F1 F2
– Fully qualified names
– No 3rd party JARs
– Needed for runtime
8
9. Dependency Finder
Implicit Dependencies
• Derived from explicit
P1 P2
• Minimize
C1 C2 – Reduce space
– Augment time
F1 F2
• Maximize
– Augment space
– Reduce time
9
11. Dependency Finder
Package Instability (from Robert C. Martin)
Number of classes outside the package that
Ca depend upon classes inside the package.
Number of classes outside the package that
Ce classes inside the package depend upon.
Ce
I = Ca + C e
• 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
12. Dependency Finder
A vs I Graph (from Robert C. Martin)
1
uselessness • Depend on abstract
packages
A
+
A • Concrete packages
I–
1
=
should have no
0
pain dependents
0 I 1
12
13. 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
17. Dependency Finder
Package-to-Package Example
Excluding /java/
Don’t list dependencies on anything with java
17
18. Dependency Finder
Why Do I See java <-- jeantessier?
Scope
P1 P2
Factory
Filter
C1 C2 P1 P2 Factory
F1 F2 C1 C2 P1 P2
F1 F2 C1 C2
original
copy F1 F2
18
33. Dependency Finder
Perl Regular Expressions
• [A-Z] Capitals
• w Alphanumeric [A-Za-z0-9_]
• W Non-alpha [^A-Za-z0-9_]
• w+ At least one alphanumeric
• s Space, including tab and eol
• s* Zero or more white space
• . ‘.’ as opposed to any character
33