There is one general design pattern that has stuck in my head for the last couple of hours, and it continues to listen to me because I do not remember its name.
I cannot remember the name, but at least I could describe it.
The design is designed to load libraries at the appropriate time to facilitate the work of users, since they do not need to wait for unnecessary loading times. It is usually used when starting a program.
Below is pseudo code in python
main.py
#main.py import platform if platform.system() == "Darwin": from QwertyMac import QwertyMac as Application elif platform.system() == "Windows": from QwertyWindows import QwertyWindows as Application elif platform.system() == "Linux": from QwertyLinux import QwertyLinux as Application else: print "platform is not supported" exit() app = Application() app.run()
QwertyMac.py
#QwertyMac.py import sys, thread, time # and other 50++ libs.
QwertyWindows.py
#QwertyWindows.py import sys, thread, time # and other 50++ libs.
QwertyLinux.py
#QwertyLinux.py import sys, thread, time # and other 50++ libs.
As you can see above, sys, thread, time and other similar libraries can be simply imported to main.py to reduce the file size, but we donβt want to create software that takes 1 minute to start just to say that it the platform is not supported, and so we moved it to where they really belong.
Any clues what is called this design?
source share