AI Briefing
KO

Improving Code Quality - Session 49: Dependency Between Substance and Illusion

·2025.10.17 11:00

Key point

This analyzes the problems that arise when sharing object instances to share logic, and presents a way to design by distinguishing between type dependency and object dependency.

1 / 2

Details

Let's assume a structure where, in order to reuse the logic of BazUiComponent commonly used in FooLayout and BarLayout, a single instance is shared between the two layouts.

This approach causes the following design problems:

  • Circular dependency occurs between the layouts and the component
  • It becomes difficult to create UI element instances inside BazUiComponent
  • The parent class Screen ends up having to know about the component, which is a detail of the layout

The root cause of this problem lies in confusing dependency on Type with dependency on Object.

When only logic needs to be shared, the type should be shared, but each layout should have its own independent BazUiComponent instance. This separates state and simplifies the dependency structure, improving code quality.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.