Skip to content
Ameen Abozaid
Planned lessonJNR-009-L06

Circular dependencies and how to avoid them

  • Lesson 6 of 8
  • Junior
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

recognize and remove a cycle.

Planned topics

  • A needs B and B needs A: with constructors Spring cannot build either, and fails at startup.
  • @Lazy can hide the cycle but not fix the design.
  • A cycle means responsibilities are tangled.
  • Fix: extract the shared part into a third class, or move the call to an event or a method parameter.
Draft outline details

Demonstration

OrderService ⇄ InventoryService; extract StockPolicy that both use.

Check your understanding

Why is @Lazy a poor fix?

Show answer

It hides a design problem instead of removing it.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.