AI Briefing
KO

Kakao FE Identifies Refactoring Points Using Dependency Instability Metrics

·2021.01.12 00:00

Key point

Identifies code deviating from design intent using instability metric (I) based on Angular module FanIn/FanOut

1 / 15

Details

The Kakao FE Platform team introduced a method for identifying structural refactoring points in the Angular-based 'OpenBuilder' project by utilizing dependency graphs and the Instability metric (I). To address the issue where code deviates from the original design intent after being modified by multiple developers, they applied a method that quantifies and verifies whether the direction of dependencies between modules is correct.

Structural Analysis via Instability Metric (I)

Based on Robert C. Martin's 'Clean Architecture', the instability metric I is calculated as a value between 0 and 1 by measuring a specific module's FanIn (incoming dependencies) and FanOut (outgoing dependencies). A value closer to 0 indicates a 'stable' state used by many modules, while a value closer to 1 indicates an 'unstable' state that uses many other modules. An ideal design establishes dependencies in the direction where unstable modules use stable modules.

Application to Real Projects and Problem Discovery

Analysis of OpenBuilder's dependency graph showed that the common library SharedModule had a low I value, and the entry point AppModule had an I value of 1, consistent with the design intent. However, reverse dependencies were discovered in some modules, such as the stable SharedModule re-exporting unstable modules.

The key problematic modules identified are as follows:

  • StandaloneTestModule: A test-only module no longer in use, isolated with a FanIn of 0
  • TutorialGuideModule: Causes reverse dependencies by unnecessarily re-exporting SharedModule
  • BotTestDialogModule: Similar to TutorialGuideModule, needs to break or reverse its relationship with SharedModule

Extensibility

This analysis method can be utilized beyond simple refactoring to quantify the impact of module changes on the entire system or to set test coverage priorities based on instability metrics. Additionally, a method for calculating more precise instability metrics by weighting the absolute values of FanOut and FanIn was proposed.

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.