Causes and solutions

As we have already seen, circular dependency mostly occurs as a result of bad design/coding practice. In large software application development, the coders may deviate from the context and produce a circular reference.

To overcome this, you can take the help of various tools to find unwanted circular dependencies. This should be an ongoing activity and be applied from the beginning of the development cycle. For example, Eclipse has a plugin called Java Dependency Viewer, which will help to see the dependency between classes and Java packages. 

Issues of circular dependency can be addressed by following certain patterns and principles, which are discussed in the following sections.

Get Java 9 Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.