Login  

Blog Stats

News

Web 2.0 University(tm)


New: Subscribe via e-mail

Enter your email address:

Delivered by FeedBurner


Your Ad Here

Post Categories

Archives

Blogs Read By Me

Building Blocks of Great Systems

Consulting

Contact

Tech News Read By Me


Head First Design Patterns:

Don't reinvent the wheel, use the most insanely great book on design patterns yet written.

Listed on BlogShares

Dion Hinchcliffe's Blog - Musings and Ruminations on Building Great Systems

Lightweight Processes, Service-Orientation, Enterprise Architecture, and Software Development

The Inversion of Control principle has been getting plenty of attention in software architecture circles over the last year or so. The big question is whether it should be getting so much attention in the same vein with arguably "serious" architecture developments, like service-orientation.

I personally am torn since IoC, and its little brother, Dependency Injection, solve real problems on a daily basis for software designers and architects. IoC is a terrific way for a component to state explicitly, and also make configurable, its dependencies on other components, systems resources, etc. IoC also makes the increasingly automated world of software testing that much easier by giving test harnesses the control to inject dependencies. Test harnesses can send in mock objects that haven't been developed yet or run faster than the real thing. So in addition to real, practical day-to-day benefits, IoC gives us effective architectural control like pliability and pluggability using a pretty straighforward mechanism. So, what's not to love about that?

Well, a couple of things, and this is partially holding IoC back from real greatness. First, IoC technically breaks encapsulation since the implementation internals of an object, especially its critical dependencies, are exposed and changeable. This makes it easy to break the Liskov Substitution Principle, probably one of the most important concepts in a software engineer's toolbox. And second, since dependencies are now moved from within the object itself, to an external component, which often keeps the information in an non-verified configuration file, it makes typing, configuration management, and interface complexity a big headache.

Figure 1: Simple Inversion of Control

Fortunately, the IoC story continues to develop and get better. I just came across Sony Mathew's articulate new treatise on IoC that was just posted on TheServerSide. In it, Sony discusses a much more streamlined new version of IoC, known as Context IoC, that doesn't use messy constructor dependency setters and has many powerful composability features. I am struck and encouraged by the power and simplicity of Sony's approach. I'm taking this as partial evidence of IoC's ongoing maturation, as well as the very cool new dependency injection features going into EJB 3.0, plus tons of exciting things happening in the industry (see Howard Ship's comments on the HiveMind/PicoContainer faceoff as one small example).

In the end, IoC is here to stay, and I think encapsulation and LSP worries are explained away in a component-based world where all components must be a client and have explicit clients (ala UML's modeling the seams). The final arbiter will be the effectiveness of any tradeoff of malleability vs. stability. IoC creates a pivot point between the two since quick and easy non-compile time dependency changes can cause sudden, unexpected changes in system behavior for no externally obvious reason. For now however, I think the advantages are greater than the disadvantages and I'm casting my vote with IoC for now. I do, however, reserve the right to change it later. :-)

Technorati: , ,

posted on Thursday, February 24, 2005 4:46 PM

AddThis Social Bookmark Button

What People Are Saying About This Post...

# Looking at Context IoC 4/7/2005 1:54 AM magpiebrain
A critical look at contextual IoC

# re: Inversion of Control: The story unfolds, but is it important? 4/7/2005 12:15 PM Bruce Atherton
I have to admit, I am confused by your claim that IOC makes it easy to break the LSP in your programs. If anything, I would have thought that it promotes it.

Ideally, you want to program to Interfaces. IOC containers make that much easier to do. Properly used, you would:

a) wire your implementations together in the IOC container
b) write your implementations to only use interfaces for its dependencies.

If you don't write your implementation this way then the IOC container buys you very little, since you can't substitute new implementations through IOC.

When you construct your programs this way, adherence to the LSP is much, much more likely in my experience. Sure, any one implementation is exposing its dependencies. But because all implementation dependencies are interfaces, an implementation cannot rely on the implementation details of its dependent objects. Thus, dependent objects have to be substitutable in the LSP sense.


# re: Inversion of Control: The story unfolds, but is it important? 4/8/2005 11:28 AM Dion Hinchcliffe
Hi Bruce,

Thanks for posting. I think IoC promotes adherence to LSP in the same way that driving in a car promotes seatbelts. You become keenly aware of the downside of the tool when things go wrong.

The original definition of LSP, by Barbara Liskov, was:

What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T." - BarbaraLiskov, Data Abstraction and Hierarchy, SIGPLAN Notices, 23,5 (May, 1988).

In this way, IoC certainly allows the behavior of a type to change suddenly and unexpectedly without the knowledge of the developer, compiler, or the testing process. I'm just concerned that folks, especially more junior designers, will not fully appreciate the power of the IoC tools in their hands and make big mistakes fairly easily.

# re: Inversion of Control: The story unfolds, but is it important? 9/25/2006 5:04 AM levan
http://www.pic-leia-haristikos.gamisi69.com ^^^ http://www.free-pahys-haristikos.gamisi69.com ^^^ http://www.blyg-sjukskoterska-full.knulla69.com ^^^ http://www.hetast-servitris-ejakulation.knulla69.com ^^^ http://www.perfect-schoolmeisje-plassend.grotepik.info ^^^ http://www.mooier-grietjes-pijpbeurten.grotepik.info ^^^ http://www.varp-sykepleier-puling.kukk.info ^^^ http://www.museaktig-ung-grupper.kukk.info ^^^ http://www.dechirer-blondes-double-oral.torsenue.info ^^^ http://www.ridicule-serveuse-fist.torsenue.info ^^^ http://www.perifronitikos-magoula-omadiko.tsoula.info ^^^ http://www.adranis-moro-mouni.tsoula.info ^^^ http://www.amichevole-asiatiche-sesso.vacche.info ^^^ http://www.bramare-allievo-spogliarello.vacche.info ^^^ http://www.natein-nuori-koura.huora.info ^^^ http://www.nakymaton-tytot-kusi.huora.info ^^^ http://www.servitrise-lort-pa-soverommet.knulle.info ^^^ http://www.varmere-skolepike-rompepuling.knulle.info ^^^ http://www.sympatiek-meisje-dronken.neuker.info ^^^ http://www.kouder-serveerster-masturberen.neuker.info ^^^ http://www.alskvard-lesbisk-suga-av-den.spermiedos.info ^^^ http://www.skygg-sekretar-dubbel-rovpuling.spermiedos.info ^^^ http://www.seks-em.ah.xsx.pl ^^^ http://www.lesbijki-black-ebony.uh.xsx.pl ^^^

# 12 Things You Should Know About REST and WOA 4/8/2008 9:42 AM Dion Hinchcliffe's Blog - Musings and Ruminations


# 12 Things You Should Know About REST and WOA 4/8/2008 9:42 AM Dion Hinchcliffe's Blog - Musings and Ruminations


# 12 Things You Should Know About REST and WOA 4/8/2008 9:44 AM Dion Hinchcliffe's Blog - Musings and Ruminations


What do you have to say?

Title:
Name:
Url:
Comments: 

Protected by Clearscreen.SharpHIPEnter the code you see: