views:

56

answers:

1

In what concrete web project(s) (you don't have to name them by name of course), specifically what part of the web-application/website, that you have worked on, has dependency injection proven to be a good choice. Can you give concrete examples where you actually substituted one component for another with DI during the life span of the project, excluding cases for mock/unit testing?

+1  A: 

Dependency injection is not about substituting components. It's about decoupling code, it helps keep cohesion high and coupling low.

Substituting components is just one (and not too common in my experience) of the things you can do with DI.

If you really want examples of substituting components:

  • I had a faxing service that connected to a remote Windows Fax Server to send faxes. I replaced that with a service that sends faxes via j2.com instead.
  • I had a service to search "stuff". This service was implemented first against a RDBMS, later was replaced with a search against a Solr instance.
  • The application cache was abstracted as a component. First it was implemented using the ASP.NET builtin cache, later it was replaced using memcached.
Mauricio Scheffer