17
shouts

How not to do Dependency Injection, in NerdDinner - Jimmy Bogard - Los Techies

published 249 days, 11 hours, 29 minutes ago posted by StevesSteves 250 days, 12 hours, 10 minutes ago
Monday, July 06, 2009 12:20:09 PM GMT Sunday, July 05, 2009 11:39:04 AM GMT

Checking out the NerdDinner code the other day, I found a common Dependency Injection anti-pattern.  One of the core concepts of DI is that components are not responsible for locating their own dependencies.  The code went part of the way to full-on DI, but not quite far enough.  Here’s the offending code:

public class SearchController : Controller {

IDinnerRepository dinnerRepository;

// // Dependency Injection enabled constructors

public SearchController() : th...

category: ASP.NET | clicked: 101 | | source: www.lostechies.com | show counter code
tags: ASP.NET, ASP.NET MVC, ASPNETMVC, dependency injection, NerdDinner, Refactoring, StructureMap