I am writing an experimental graphical shell. A GUI is created by combining components (similar to widgets). There are several “native” component classes. The framework user specializes in providing specific methods that define configuration, bindings, etc. This can be done by expanding your own class and overriding its methods, which is good, but many derived classes will be created only once. Alternatively, I could provide a factory function that will take its own class and specialized methods (functions, really). This function will instantiate its own class and replace the corresponding methods. Any reason to prefer one approach over another?
The Monkey patch is not a real design pattern, more like a hack, which leads to spaghetti code due to abuse.
What you probably want as an alternative to replacing monkeys is adapters or aspect-oriented programming .
What most GUI tools (wxpython, kivy, pyQT) in python do is an inheritance approach.
I assume that both approaches should work, but using inheritance will be more familiar to your potential users.
, , (suck kv lang html) ,
Source: https://habr.com/ru/post/1623671/More articles:How can I handle warnings generated by Boost.Spirit? - c ++How to set a repeating alarm that will work even in the "Dose" mode? - performanceRuntimeWarning: invalid value encountered in long_scalars - pythonLaravel not working - phpWhy is my program printing garbage? - c ++Renderer can not be used in the service? - angularMark text in R - textКак использовать классы Unreal 4 ProcessuralMeshComponent в коде? - c++Formatting IntelliJ JSP - intellij-ideaHow to smooth nested lists in PySpark? - pythonAll Articles