Friday, September 25, 2009

Architecture Astronautics - Dependency Injection

Dependency injection is like crack for architecture astronauts.

Here's why this pattern sucks:

1) Abstraction behind dynamically loaded interfaces makes it harder to understand and debug the code. Time is money, developers take longer, money is wasted. Hard coding and recompiling, while less elegant, works, saves time, and makes everyone's life easier.

2) You aren't going to need it.

The only semi-practical implementation of this pattern that I have seen, is swapping databases or services so that development or testing can continue in an incomplete system. I say semi-practical because even when lip service is given to the correct circumstances the implementation has always been so awful that any theoretical gain is lost. I've also seen core business logic implemented in this pattern, which in an enterprise, is a complete waste of time. In short, I've never seen an application of dependency injection that saved a company money.


Hard code your dependencies.
Don't be afraid to recompile.

No comments:

Post a Comment