Dependency Injection with Google Fruit
Page Status
This page is a placeholder. Content coming soon.
Focused page on the DI system. Fruit is not widely used in C++ projects, so contributors need explicit guidance.
Why DI in Porytiles: testability, runtime conditional binding (TTY detection for formatter selection), decoupling
Google Fruit basics for contributors who have not used it: components, injectors, binding
The composition root: where the injector is created (in
tools/driver/command handlers)Current DI components in
xcut/di/components.hppRuntime conditional binding walkthrough: how
--no-colorflag and TTY detection flow throughDI migration status: most services still manually instantiated in command handlers (migration planned)
Testing with DI: using mock implementations,
BufferedUserDiagnostics,NullUserDiagnostics
Note: The step-by-step recipe for adding a new DI-managed service has been extracted to How to Add a DI-Managed Service in the How-To Guides section.
Cross-references: Layered Architecture and DDD for why interfaces live in domain, External Dependencies for Fruit library details, How to Add a DI-Managed Service for the step-by-step recipe