Search code examples
oopdata-structuresdirected-acyclic-graphsbinary-decision-diagram

What is the benefit of being able to map a system's dependencies as a DAG (directed acyclic graph)?


If I were to organize a collection of objects' dependencies into a DAG, in what situations would that be more desirable than another data structure such as a BDD (binary decision diagram)?


Solution

  • The DAG has a couple of properties which are ideal for analyzing dependencies.

    First, you can easily identify the 'base level' components of your system. Those are the nodes in the DAG with no edges going into them. Knowing the relative layers of your system means you know the impact of refactorings. (Everything down the chain.)

    Second, if you can produce a DAG you know that the system has no strange inter-dependencies. Cycles in the dependency graph would mean that you have two components which rely on one another -- a recipe for strange bugs and build errors. At Microsoft we used a tool called asmmeta to work around this issue.