Skip to content

refactor(di): decompose Ctrl god object via constructor injection (#208) - #214

Merged
pajoma merged 1 commit into
developfrom
feat/208-constructor-injection
May 17, 2026
Merged

refactor(di): decompose Ctrl god object via constructor injection (#208)#214
pajoma merged 1 commit into
developfrom
feat/208-constructor-injection

Conversation

@pajoma

@pajoma pajoma commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace constructor(public ctrl: JournalController) with narrow sub-interface params in all seven action/UI modules (Inject, Parser, Writer, Reader, Dialogues, ConsoleLogger, ScanEntries)
  • Ctrl becomes a two-phase object: constructor creates Configuration only; initServices(logger: ILogger) creates all services in dependency order
  • 14 test files updated from ctrl.logger = logger to ctrl.initServices(logger); new J.Actions.Parser(ctrl) calls replaced by ctrl.parser

Test plan

  • npm run compile — zero errors
  • npm run lint — zero new warnings
  • npm test — 126 tests pass (verified locally)
  • grep -rn "this\.ctrl" src/actions/ src/ext/dialogues.ts src/util/logger.ts src/provider/features/scan-entries.ts — no output (verified)

Related

🤖 Generated with Claude Code

Replace `constructor(public ctrl: JournalController)` with narrow
sub-interface params in all seven action/UI modules. Ctrl gains a
two-phase init: constructor creates Configuration only; initServices(logger)
creates all services in dependency order. Tests updated from
`ctrl.logger = logger` to `ctrl.initServices(logger)`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pajoma

pajoma commented May 17, 2026

Copy link
Copy Markdown
Owner Author

Architecture Review Approval (PR #214)

I have reviewed the implementation of PR #214 and it is perfectly aligned with the approved plan.

Key Achievements:

  • Dismantled God Object: The transition from ctrl: JournalController to focused constructor parameters across all seven action/UI classes is a massive win for architectural clarity.
  • Improved Initialization: The two-phase initialization (initServices) correctly manages our dependency graph while preventing the circular instantiation risks we identified in the audit.
  • Cleaner Tests: The migration of the test suite not only fixes the initialization pattern but also simplifies tests by utilizing the controller's internal service registry.
  • SRP Integrity: Pushing ConsoleLogger construction into the Startup layer successfully keeps VS Code UI concerns out of our central controller.

This refactoring provides the definitive foundation for independent unit testing and long-term maintainability.


Note: Gemini was involved in creating this comment (but not without consulting me).

@pajoma
pajoma merged commit 5c85e26 into develop May 17, 2026
2 checks passed
@pajoma
pajoma deleted the feat/208-constructor-injection branch May 17, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arch: Decompose God Object Controller into Focused Dependencies

1 participant