liveBook · Manning

Circular dependency

As explained in Grokking Software Architecture

A cycle in which components depend on one another, directly or through other components, forming a closed dependency path.

A circular dependency forms when components depend on one another in a closed loop—for example, when Layer A depends on B and B depends on A. In a layered system, an infrastructure component calling the UI directly can create this upward dependency. section 4.3.2

The cycle makes the system brittle and hard to understand. A clearer route is for infrastructure to return data to the Application Layer, which decides how to notify the presentation layer. section 4.3.2

Repository calls the UI

A repository that saves data and directly updates a presentation-layer status label couples data access to the UI, making isolated testing harder. section 4.3.2

Figure 4.5 In a clean architecture, dependencies must only flow downward to the adjacent layer. Breaking this rule by "skipping" layers or creating upward dependencies (e.g., the Infrastructure Layer talking directly to the UI) creates a tangled web that makes the system impossible to test or modify without breaking everything.

Use the figure to see how upward dependencies can tangle layers that should depend downward. section 4.3.2

How Grokking Software Architecture covers it

How deep it goes
Explains a cycle’s brittleness and an orchestration alternative, stopping at architectural guidance rather than implementation details.
Examples
Uses a repository that calls the UI directly to show upward coupling and its testing costs.
What you can do after
Diagnose brittle layer dependencies and route notifications through the Application Layer after infrastructure returns data.
How it connects
Links circular dependencies to layered architecture, separation of concerns, replaceability, and testability.

Also explained in

Compare how 7 books explain circular dependency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.