More Context IoC

Thanks go to Ade for providing me with many fun links and this insightful comment:

If you find yourself seeing duplicated signatures containing lots of arguments to constructors it usually indicates a missing abstraction which would bring together all those dependencies. So instead of having:
public FootBallGame(RuleValidator rv, TimeKeeper tk, RuleEnforcer er, WhistleBlower wb, …)

you would have:
public FootBallGame(Referee r)

and the referee would then play all those roles.

This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to More Context IoC

  1. anonymous says:

    The thing though is that really is not IoC. It is more like good class design. Sure it may help in IoC, but I do not agree we creating objects to support a design style…your design style should be flexible around your objects

  2. sirenian says:

    I know it’s not pure IoC. I was looking for something which lay somewhere between true IoC and “Contextual IoC”, and most particularly, something which worked better than calling a batch of common constructor dependencies “context” or “toolbox”. If I was coding this I certainly wouldn’t start with a Referee – but given enough changes to the FootBallGame, I might refactor and add one.

  3. anonymous says:

    None of this is IOC. It’s just dependency injection or object orientation if you’re old-fashioned.

    IOC is about your code being called by the framework you’re using. See John “Gang Of Four” Vlisside’s book from 1998 ( for a good definition that talks about IOC as the concept that distinguishes libraries from frameworks. I really wish people wouldn’t hi-jack perfectly meaninful terms. Not least because I sound like a middle-aged curmodgeon when I try to get people to avoid reinventing new names for old ideas.


  4. sirenian says:

    I am reprimanded and will add this book to my reading list.

    (See my userinfo to work out how likely it is that I’ll get around to reading it, but thank you very much for the shortened version!)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s