CodePark/ questions / Dependency injection & inversion
START PRACTICINGPRACTICE
Backend question · Software design & patterns › Dependency injection & inversion

In a hand-wired (container-free) application, where should the object graph be assembled?

In one place near the entry point, often called the composition root, such as main.ts

Build the object graph in one place near the entry point, such as main.ts. This place is called the composition root. The object graph is the set of objects and the links between them. The composition root chooses the concrete classes and wires them together. Every other class just receives its dependencies.

"In a global registry that services query when they need something" is wrong. That is the service locator pattern, and it hides dependencies.