#offtopic Can anyone clarify few questions about D...
# tornadofx
#offtopic Can anyone clarify few questions about DI containers/frameworks? I don't have issues with understanding DI as mechanism/concept, but I can't understand it's place in program execution flow. I don't really get the difference between context/module/container, so I'll use
in such places, because it depends on framework ? As far as I get, the simple flow looks like this: 1. Before starting event loop we initialize context (set of containers/modules), which knows how to map interface A to implementation B. These bindings may specify how dependency must be created (single instance, new instance per call, new instance per scope ? (not sure about the last one)) 2. Object created inside DI is analyzed inside DI for @Inject/other annotations and code generation happens (providing required dependency based on module mapping). 3. Once the root/entry object is created inside DI, chain of modifications happens to all code graph accessible from this point. DI knows about every object, and by using its context/container/modules, instance of dependency is provided ? 4. To create child container/context (like a tree), so you can provide more accurate implementation for this particular module. You need reproduce step one, and somehow bind child context to parent? You are free to use extra annotations to narrow the search, for example if you need both parent and child implementations ? 5. You are responsible for context disposal, which happens on the same level as creation ? 6. Basically DI has no real runtime (like thread or something), it's just clever code generation and delegation of control ?
stackoverflow 1
google 1