Python Module Design Concept:
- Always write code within a Python module: Wood has the means to write code that is not within a module, in fact, the program code entered at the interactive mode prompt is actually inside the built-in module __MAIN__. The interactive mode prompt is unique in that the program is discarded immediately after execution and the expression results are automatically printed
- Module coupling to the lowest: global variables, just like functions, if written into a closed box, the module runs best. The principle is that the module should be as free of shared global variables as possible with other modules
- Maximize the adhesion of the module: the same target. The coupling of the module can be minimized by maximizing the adhesion of the module, which is unlikely to depend on the external variable name if all elements of the module want to have a common purpose.
- Modules should be less able to modify the variables of other modules
module is object: meta-Program
Because the modules show most of their interesting features through built-in properties, it is easy to write programs to manage other programs. Called this kind of program as meta-Program
Python Module design Concept