際際滷

際際滷Share a Scribd company logo
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                                          B
source               outbound           inbound                  target
dependent                                                   dependable



 UML:       C1                                         C2


            P1                                         P2
                                                   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
P1    P2
              Class inheritance via
               extends keyword
C1    C2
              Interface realization via
F1    F2       implements keyword
              From fields and methods
               of the class


                                 4
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
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
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
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
Dependency Finder



Implicit Dependencies
             Derived from explicit
P1     P2
             Minimize
C1     C2       Reduce space
                Augment time
F1     F2
             Maximize
                Augment space
                Reduce time

                                  9
Dependency Finder



Implicit Dependencies

  classes of        features of            self
  a package           a class

       P                      P               P

  C1       C2                 C               C

  F1       F2       F1              F2        F



                                         10
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
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
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                  dependencies
      dependents
                                             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/
Dont list dependencies on anything with java
                                      17
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
Dependency Finder



Package-to-Package Example




         Excluding /^java/
  Dont 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/
    Dont 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 /NodeFactory/
   Calls to methods of NodeFactory
                                  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-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
Dependency Finder



The End



depfind.sourceforge.net



                              34

More Related Content

Dependency Finder Tutorial