HOME

TheInfoList



OR:

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''". This implies that the dependencies form a
directed acyclic graph In mathematics, particularly graph theory, and computer science, a directed acyclic graph (DAG) is a directed graph with no directed cycles. That is, it consists of vertices and edges (also called ''arcs''), with each edge directed from one ve ...
.


Example

In this UML
package diagram A package diagram in the Unified Modeling Language depicts the dependencies between the packages that make up a model. Overview In addition to the standard UML Dependency relationship, there are two special types of dependencies defined betwe ...
, 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 A software bus is a software architecture model where a shared communication channel facilitates connections and communication between software modules. This makes software buses conceptually similar to the bus term used in computer hardware for in ...
. 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 In object-oriented design, the dependency inversion principle is a specific methodology for loosely coupling software modules. When following this principle, the conventional dependency relationships established from high-level, policy-setting ...
* Create a new package, and move the common dependencies there.


See also

* Package principles *
Circular dependency In software engineering, a circular dependency is a relation between two or more modules which either directly or indirectly depend on each other to function properly. Such modules are also known as mutually recursive. Overview Circular depend ...


References

{{Reflist Software design