Simulator
Dependency Injection
Toggle between tight coupling and constructor injection. Same layers — completely different testability and flexibility.
Controller
creates Service with new
creates
Service
creates Repository with new
creates
Repository
creates Database with new
creates
Database
concrete Postgres only
Problems
- Tight coupling to concrete classes
- Hard to unit test (cannot swap fakes)
- Poor maintainability as the graph grows
users.controller.ts
class UsersController {
private service = new UsersService(); // tight!
}