Muhammed Senussi
Muhammed Senussi
  • Muhammed Senussi
Dependency Injection Without a FrameworkJava

I like Spring. I also think a lot of code reaches for a container before it has a problem a container solves.

What you actually get

A container gives you lifecycle management, scoping and a place to hang cross-cutting concerns. If your object graph is a few dozen singletons wired at startup, you are paying for all three and using one.

Wiring by hand in a single composition root is unfashionable and remarkably clear: the whole graph is one file you can read top to bottom, startup order is explicit, and tests construct exactly what they need without a context to boot.

Reach for the container when the lifecycle gets interesting. Request scopes, proxies and declarative transactions are real work you should not rewrite.

0 Comments

  • No comments yet.

Leave a comment