Problem statement
Design the object model and public APIs for a dependency-injection container that wires an application's objects together: a developer registers how each type is created, then asks the container to resolve a fully constructed object graph.
Operating context. One in-process library. It must let callers register a service by its interface/type using a concrete implementation, an eager instance, or a factory; resolve a requested type by recursively constructing its constructor dependencies; support lifetimes (singleton per container, transient per resolve, scoped per child scope); allow multiple named/keyed registrations for one interface; and create child scopes that dispose what they own. A root container spawns child scopes, and resolution may run concurrently from many threads.
Out of scope. The reflection or annotation-scanning mechanics of any one language, AOP/proxy interception, binding from configuration files, hot-reload of registrations, and container-managed transactions.
What to produce. The class hierarchy (container, binding descriptor, lifetime strategies, resolution scope, resolver), the public APIs (register, resolve, create-scope), and the resolution algorithm. Be explicit about: how lifetimes are implemented so a singleton is created exactly once under concurrency, how circular dependencies are detected without a stack overflow, and how a scope disposes the instances it created.
Requirements
This assessment is a Premium feature.
The statement above is free to read. The functional and non-functional requirements, and the graded canvas that scores your design against them, come with Premium.
Topics
- System Design LLD
- Oop Solid
- Patterns Strategy
- Patterns Factory
- Concurrency Locks