Harman Patil (Editor)

Acyclic dependencies principle

Updated on
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Acyclic dependencies principle

The acyclic dependencies principle (ADP) is a software design principle that states that "the dependency graph of packages or components should have no cycles". This implies that the dependencies form a directed acyclic graph.



In this UML package diagram, package A depends on packages B and C. Package B in turn depends on package D, which depends on package C, which in turn depends on package B. The latter three dependencies create a cycle, which must be broken in order to adhere to the acyclic dependencies principle.

Types of dependencies

Software dependencies can either be explicit or implicit. Examples of explicit dependencies includes:

  • Include statements, such as #include in C/C++, using in C# and import in Java.
  • Dependencies stated in the build system (e.g. dependency tags in Maven configuration).
  • Examples of implicit dependencies includes:

  • Relying on specific behaviour that is not well-defined by the interface exposed.
  • Network protocols.
  • Routing of messages over a software bus.
  • In general, it's considered good practice to prefer explicit dependencies whenever possible. This is because explicit dependencies are easier to map and analyze than implicit dependencies.

    Cycle breaking strategies

    It is in general always possible to break a cyclic dependency chain. The two most common strategies are:

  • Dependency inversion principle
  • Create a new package, and move the common dependencies there.
  • References

    Acyclic dependencies principle Wikipedia

    Similar Topics
    Tora san to the Rescue
    Raymond Burse
    Midori Kono Thiel