Click here to Skip to main content
13,201,050 members (55,996 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Reading through:
and reading the chapter on DIP (dependency inversion principal, the first example by Jimmy Bogard, is slightly confusing.

in his example he takes a class that has two dependencies in the method he wants to use and he then extracts them out as interfaces to decouple these two dependencies from the class. Ok! Good! He then passes the interfaces into the constructor so that he has them to use. Good again.

But he doesn't extract out a third object he is passing into the method that he uses in the method, as if this object being passed in isn't a dependency.

My question is: if you are passing in a concrete implamentation of an object into anotherobject method, isn't that a dependency, regarless of when or how it is being used in the method?
In order to trully make it decoupled, don't all object being passed around have to be abstracted out as interfaces and passed into the calling object via interface?
Posted 21-Nov-12 14:10pm
Sergey Alexandrovich Kryukov 21-Nov-12 20:37pm
Why no asking the author? I personally don't see a problem with dependency inversion, but locating this sample in a book...
However, it might be an interesting book. I'm printing it to read later. I'll try to pay attention for this example (please, give me the exact section/page) and will try to tell you what I think. Please, not a firm promise -- sorry. I'll just try.
chuckdawit 21-Nov-12 20:39pm
just look at the section on DIP. its the first example in that section.
Sergey Alexandrovich Kryukov 21-Nov-12 20:55pm
It looks like this is the example with the description of the problem, not the solution the author suggests...
chuckdawit 21-Nov-12 20:58pm
look on page 62, the example starts on page 62. The object 'Order' is being passed into the method as a concrete implementation, even after he refactors out the dependencies he still uses 'Order' as a concrete implementation. He doesn't create and pass in a IOrder interface like you would expect to see.
Sergey Alexandrovich Kryukov 21-Nov-12 21:59pm
I see, thanks for clarification. I'll read it later.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171020.1 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100