A circular dependency is rarely written on purpose. It shows up one reasonable import at a time — a service that needs a helper, a helper that needs a constant from the service — until three classes can no longer be changed without the other two. This guide covers how to find them in Java, TypeScript, Python and Go, how to break them, and how to stop new ones in code review.
Why they matter
Changes ripple. Every class in the cycle can be affected by a change to any other.
Testing gets heavy. To test one piece you have to construct the whole cycle.
Runtime bugs. In Node.js a circular require or import can hand you a module that hasn't finished initialising, so a value is undefined at load time. Spring Boot has refused circular bean references by default since 2.6.
Splitting becomes impossible. A cycle can't be extracted into separate services or packages without breaking it first.
Java
ArchUnit lets you write the rule as a unit test, failing the build when packages form a cycle:
slices ().…