Several There are several well-known adages in Object-oriented design that suggest that the dependency structure of a package or module must never contain cycles, or in other words, must orchestrate a Directed Acyclic Graph (DAG).
There are several pros advantages of eliminating cycles between packages:
...
Noncompliant Code Example
This noncompliant code snippet example features two different packages named Account and User that consist of the classes AccountHolderClass and UserClass, respectively. The class UserClass extends from AccountHolderClass as an account holder can be any kind of user or owner. AccountHolderClass depends upon a few utility methods defined in UserClass and must declare its instance. Likewise, the UserClass depends on AccountHolderClass but instead chooses to extend from it. This vicious use is one recipe for a circular dependency.
...
The tight coupling between the classes in the two separate packages can be weakened by introducing an interface called BankApplication in a third package, Bank. The circular dependency is eliminated by ensuring that the AccountHolderClass does not use an instance of UserClass, but instead relies on the interface by importing the Bank package. In this solution, such functionality is achieved by introducing a parameter of the interface type BankApplication to the depositFunds() method. This gives the AccountHolderClass a solid contract to bank upon. Additionally, UserClass implements the interface and provides concrete implementations of the methods while at the same time, inheriting the others from AccountHolderClass.
...