Acyclic dependencies principle explained

The acyclic dependencies principle (ADP) is a software design principle defined by Robert C. Martin that states that "the dependency graph of packages or components should have no cycles".[1] This implies that the dependencies form a directed acyclic graph.

Example

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.[2]

Types of dependencies

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

Examples of implicit dependencies includes:[3]

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:[1]

See also

Notes and References

  1. Web site: Granularity: The Acyclic Dependencies Principle (ADP). Object Mentor. 2022-11-15. 2015-11-30. https://web.archive.org/web/20151130032005/http://www.objectmentor.com/resources/articles/granularity.pdf. bot: unknown.
  2. Book: Fowler, Martin . UML Distilled . 2004.
  3. Web site: Implicit Dependencies Are also Dependencies. O'Reilly. 2013-06-16. https://web.archive.org/web/20130525055437/http://programmer.97things.oreilly.com/wiki/index.php/Implicit_Dependencies_Are_also_Dependencies. 2013-05-25. dead.