Skip to search.
altdotnet · Alt Dot.Net Discussions

Group Information

  • Members: 1347
  • Category: Software
  • Founded: Dec 27, 2007
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Messages

  Messages Help
Advanced
The stages of learning how to use an IoC Container   Message List  
Reply Message #10434 of 24622 |
Been thinking a lot lately about how to teach about IoC and how to use containers such as StructureMap (and others which are not worth mentioning ;)) to someone who either is coming in cold to DI/IoC or has a vague awareness of what it is.

Personally, the stages I went through (and have seen few other people go through similarly) are:

1.) Replace all (most?) new()'s with ObjectFactory.GetInstance<T>.  You get some immediate benefit out of this and it opens up some new opportunities for your code, but doesn't even scratch the surface
2.) Move to ctor injection with very explicitly defined instances/pluginfamilies/etc and not using auto-wiring.  Maybe you still even have an old-fashioned C'tor that still satisfies its own dependencies for those times when 'you might not be using an IoC container'
3.) Embrace auto-wiring, remove non-IoC/DI c'tors and trust fully the container
4.) Start using more advanced techniques like lifecycle management, profiles, convention-based dependency satisfaction, etc
5.) Auto-registration, full trust of the IoC. Thoughts start to pop up like, 'I wonder if I could get the Container to write my app for me??'
6.) ???

Do you necessarily have to go through all these stages, or is there some shortcut to get someone to unlearn procedural style code and fully embrace IoC and jump right to Level 3 or 4 quickly?

Site note: I believe I'm, personally, at level 5 right now and I'm wondering, what goes on in Level 6 that I'm currently missing out on? What about 7+?


Fri Jun 20, 2008 2:21 pm

chad.myers94
Offline Offline
Send Email Send Email

Message #10434 of 24622 |
Expand Messages Author Sort by Date

Been thinking a lot lately about how to teach about IoC and how to use containers such as StructureMap (and others which are not worth mentioning ;)) to...
Chad Myers
chad.myers94 Offline Send Email
Jun 20, 2008
2:21 pm

Well you missed "Understand Dependency Injection and Inversion of Control" ... a lot of the hardship around getting the concept of an IoC container across is...
Casey Charlton
caseycharlton69 Offline Send Email
Jun 20, 2008
2:25 pm

Yeah, good point. That's Step 0, I guess ;) I've had a few people ask me about DI or 'What does StructureMap do, anyhow?'. So they have at least the basic...
Chad Myers
chad.myers94 Offline Send Email
Jun 20, 2008
2:32 pm

Step 0.5 is then: Why on earth do I care about dependencies?...
Casey Charlton
caseycharlton69 Offline Send Email
Jun 20, 2008
2:39 pm

@Casey: If you buy into object-oriented design and separation of concerns, dependencies are everything. At its most basic level, good design is just maximizing...
Nate Kohari
nkohari Offline Send Email
Jun 20, 2008
2:49 pm

Ditto Casey & Nate. 0.) Steal underpants 0.4) Should I stop writing code as monolithic blobs of procedural code and start structuring my code into simpler ...
jeremydmiller Offline Send Email Jun 20, 2008
3:06 pm

I guess I don't fit those stages, thouugh I did go through some of them and still love IoC and dependency inversion and especially the features a container can...
Colin Jack
colin.jack Offline Send Email
Jun 20, 2008
3:36 pm

... use a container might be a bit off<<< There are many ways to achieve SoC ... I think people get too hung up on the container aspect and not what it is...
Casey Charlton
caseycharlton69 Offline Send Email
Jun 20, 2008
3:43 pm

Very recently during a code camp session, I kind of took that approach. It was a very gradual process of working towards this. These are some of the steps I...
Matthew Podwysocki
matthew.podw... Offline Send Email
Jun 20, 2008
4:01 pm

Step 6 (or 7 or 8): Start writing your own facilities or activators to suit your architecture. For example we get a proxy back for services in the presentation...
David Laribee
davidlaribee Offline Send Email
Jun 20, 2008
2:38 pm

I would say the process for moving a brownfield project to inversion of control goes like this: 1. Invert control. Introduce a service locator that's backed by...
Nate Kohari
nkohari Offline Send Email
Jun 20, 2008
2:46 pm

I'd say for me 2) and 1) were swapped. I started getting the benefits of constructor injection for testing first, and then started to get huge chains of...
Geoff Stockham
gjstockham Offline Send Email
Jun 20, 2008
3:01 pm

The timing of this is perfect. I'm going to use Structure Map on something in the next few weeks, and I work much better with a print-out. jdn ... use ... ...
jdn3times Offline Send Email Jun 20, 2008
3:09 pm

I was inspired to turn this into a blog post. Slightly different take on the same topic: http://kohari.org/2008/06/20/applying-ioc-to-brownfield-projects/ ...
Nate Kohari
nkohari Offline Send Email
Jun 20, 2008
4:20 pm

I think you need to go through them. If not in person, at least have someone go through that and explain it. Also, you need to understand DI first, and how it...
Ayende Rahien
Ayende@... Send Email
Jun 20, 2008
10:24 pm
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help