2 ms·
This does not seem to implement dependency inversion (DIP). (IIRC, Robert Martin states that DIP is one of the principles[1] on which dependency injection (DI)
by a3w 5y ago
This does not seem to implement dependency inversion (DIP).
(IIRC, Robert Martin states that DIP is one of the principles[1] on which dependency injection (DI) can be built as a pattern.)
Since python does not have interfaces (unless you write classes that to nothing, except perhaps raise errors if methods are not overwritten) this does not seem to actually do DI/IoC completely.
[1]: Together with DIP as the second principle.
<Edit>Flipped IoC (e.g. factories) and DIP (interfaces for abstraction) which I seem to had memorized with swapped meanings</edit>
- BerislavLopac 5y agoPython has protocols. But I'm not sure if they relate to this directly.
- a3w 5y ago"new" in 3.8, oh nice! For static type checking, which might help even the small to medium sized scripting projects which I usually do.
- BerislavLopac 5y ago> "new" in 3.8, oh nice You can have them in earlier versions with the typing-extensions library. [0] > For static type checking Protocols can be used for runtime checks as well. [1] [0] https://pypi.org/project/typing-extensions/ https://pypi.org/project/typing-extensions/ [1] https://docs.python.org/3.9/library/typing.html#typing.runtime_checkable https://docs.python.org/3.9/library/typing.html#typing.runti...