Replies: 1 comment
-
Let's split the question:
I would say that an “integration” level is responsible for the “wiring”. An application level is a bunch of use-cases and services, at least IMHO. These are beings that should be runnable and testable without the wiring, just like the domain. Integration level (aka External Interfaces aka Frameworks & Drivers, the blue circle) is the sphere of the runtime that relates dependency points (
Before I say anything about When it comes to runtime, the implementation of the dependency has to be delivered to the aggregate. There are some different patterns of delivery. A quite common is by call args. If a function depends on a framework service, it takes it from an arg, but types it as its own interface: # domain layer
class MailerInterface: ...
def my_function(dependency: MailerInterface) -> ...:
...
# framework layer
class MailerService(MailerInterface):
# MailerInterface can be inherited, but it can be a subclass of typing.Protocol type
# and there's no need for inheritance
# "integration" layer
my_function(dependency=MailerService()) ... but if there are more dependencies, and you have to carry them around from a function call to another function call, it can be quite arduous. Different programming styles have different solutions. Functional programming can solve the problem with Monads. Many Python styles use double star operator (aka double splat operator aka I find DI container (and the whole dependency mechanics) to be circle-agnostic. If you consider the role of the DI container to the whole system, there's nothing special about it. It wires interfaces with the implementation, across all levels. For a functional dependency, the Now, back to your question. Shouldn't it be disallowed to have And now to the main point: DI container collects (& hides details of) bindings between interfaces and the implementations. IMO the Dependency Principle is about what depending on (i.e. being controlled by) the outer world. This has little to do with the inner code calling the implementation. |
Beta Was this translation helpful? Give feedback.
-
Moved here from: #20 (comment)
The quote bellow was originally posted by @ms-lolo and the title of the topic is mine.
The Dependency rule, mentioned above, can be stated as
and can be described as in The Book.
Beta Was this translation helpful? Give feedback.
All reactions