Building out a new application now and struggling a lot with the implementation part of "Closed-Open" and "Inversion of Control" principles I following after reading Clean Architecture book by Uncle Bob.
How can I implement them in Python?
Usually, these two principles coming hand in hand and depicted in the UML as an Interface
reversing control from module/package A to B.
I'm confused because:
- Python does not possess
Interface
s as Java and C++ do. Yes, there areABC
and@abstractmethod
, but it is not a Pythonic style and redundant from my point of view if you are not developing a framework - Passing a class to the method of another one (I understood that it is a way to implement open-closed principle) is a little bit dangerous in Python, since it does not have a compiler which is catching issues may (and will) happen if one of two loosely coupled objects change
- After neglecting interfaces and passing a class to another one... I still need to import everything somewhere at the top module. And by that, the whole thing is violated.
So, as you can see I'm super confused and having a hard time programming according to my design. I came up with. Can you help me, please?
Aucun commentaire:
Enregistrer un commentaire