Git Product home page Git Product logo

Comments (7)

ploeh avatar ploeh commented on August 27, 2024

Does this answer your question? http://stackoverflow.com/a/9503612/126014

from ploeh.github.com.

 avatar commented on August 27, 2024

I don't think so.

As far as I know, dependency inversion is, because doing some task and creating instances of the dependencies in the same class would violate the single responsibility principle. So because of this we have to inject the dependencies and create classes (one or more DI container) with the task of instantiating classes...

Maybe I just misunderstood one of your graphs. The arrow from the data access library to the domain library means to me, that the domain library will be injected with dependency injection to the data access library. This is unusual to me. If I want to save something in my database I want to ask the database to save it for me, not for example trigger a persist event and listen to those events from the database... But this invertion of yours says that to me :S I am confused...

from ploeh.github.com.

ploeh avatar ploeh commented on August 27, 2024

The arrows describe references, so in this case it means that the Domain Library has references to neither User Interface Library nor Data Access Library. Instead, the Data Access Library has a references to the Domain Library.

At run-time, the objects from the Domain Library will be injected with objects from the Data Access Library, so that they can invoke their services.

This is unusual to me. If I want to save something in my database I want to ask the database to save it for me, not for example trigger a persist event and listen to those events from the database... But this invertion of yours says that to me

Well, there's a reason it's called Inversion of Control :)

Have you read my book?

from ploeh.github.com.

 avatar commented on August 27, 2024

Not yet, I don't have time to read books. :S I just found your blogpost...
Are you aware, that ppl uploaded your book to several sites?

from ploeh.github.com.

 avatar commented on August 27, 2024

At run-time, the objects from the Domain Library will be injected with objects from the Data Access > Library, so that they can invoke their services.

Hmm so the domain library is aware of the data access library objects (maybe just interfaces). It's okay then, I just misunderstood. In my approach the classes in the layers/modules do not know of the existence of each other, and a DI container instantiates and injects them into each other whenever it is necessary...

from ploeh.github.com.

ploeh avatar ploeh commented on August 27, 2024

Thanks for the heads-up!

from ploeh.github.com.

 avatar commented on August 27, 2024

You're welcome!

from ploeh.github.com.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.