2 ms·
I usually provide two to three ways to inject dependencies, especially if an object needs multiple dependencies of the same type: 1. An add_foo instance method
by BerislavLopac 5y ago
I usually provide two to three ways to inject dependencies, especially if an object needs multiple dependencies of the same type:
1. An add_foo instance method.
2. Arguments to the `__init__` method, ideally as *args, using add_foo internally.
3. Optionally, an @instance.foo decorator which inserts the dependency as it's being defined (again, using add_foo internally).