I'm not able to figure out the difference between the Dependency Inversion Principle (one of the S.O.L.I.D principles) and the general 'Code to Interfaces' or Separated Interface pattern. All of them advocate creation of a layer of abstraction to decouple the lower level and the higher level modules.
The DI principle envisages creation of interfaces to interact between the higher and lower level modules, but also insists that the interfaces must be a part of the higher level package.
Why should this be a part of higher level and not lower level ? It's is the lower level that's exposing its behavior, so shouldn't the decoupling interfaces be a part of lower level?
What if there are multiple higher level modules depending upon the same lower level?
Or else,
Why not make a separate package in which to place all the interface, which then can be used by both higher level and lower level? (This is envisaged by the Separated Interfaces pattern.)
My dilemma is, I am not able to figure out the relative use and benefits or each of them.
Please do not quote article by Derek Greer or Robert Martin. I have read those articles, but confusion still persists.
Comparison between these also exist in the Dereck Greer http://aspiringcraftsman.com/2008/12/28/examining-dependency-inversion/ – aknon Dec 20 '13 at 09:36