Bartek Szafko

all of the bits and pieces

Project Silk subjective review part 3 IoC a problem child

with 2 comments

This is part 3 of my http://silk.codeplex.com/ review.

IoC miss usage is a most common problem in many applications and first thing I usually look at.

I choose random action method called Add from FillupController:

Do you see that Using stuff, let’s have a look:

Duh, so it’s says we are creating an object using service locator, not a good practice.

What is more curious the FillUpController has no properties at all:

On the other hand there is a custom controller resolver which uses IoC Container.

Now testing a controller requires mocking IoC controller:

What I would do

  • The simplest thing: extract interfaces from all instances resolved with Using  register it in container and just put a property dependency.
  • When you look closer at all that Using calls it’s kind of miss implemented CQRS( with all that handlers stuff in my last post), but the if project is so simple so why bother?

Inne podobne artykuły:

Written by Bartłomiej Szafko

July 25th, 2011 at 6:03 am

Posted in .NET,review

Tagged with , ,

with 2 comments to “Project Silk subjective review part 3 IoC a problem child”

Subscribe comments with RSS. TrackBack URL.

  1. foobar

    30 Jul 11 at 13:46

    Dude,

    “Subjective review” is a misnomer. Reviews are ALWAYS subjective. NOBODY has ever been able to write an objective review.

Leave a Reply