|
|
|
|
|
by garethrowlands
1535 days ago
|
|
The answer is that your "composition root" constructs the objects using normal code. Usually the composition root is the `main` function. def main:
a = ...
b = ...
c = ...
my_object = MyObject(a,b,c)
my_object.do_something()
If you think it's ugly in `main`, then extract to another function: def main:
my_object = make_my_object() # constructs my_object as above
my_object.do_something()
I've used this pattern extensively in Kotlin and also php (ew). It works well in pretty much any language. |
|
Magic, monkey-patching mess of dependency injection libraries is terrible.
Dependency injection as a concept is simple functional approach to imperative and OO programming.