deepset-ai / COVID-QA

API & Webapp to answer questions about COVID-19. Using NLP (Question Answering) and trusted data sources.
Apache License 2.0
344 stars 121 forks source link

PR_1_Creational_Design_Pattern(Singleton_Pattern) #151

Open SwithinTan opened 3 years ago

SwithinTan commented 3 years ago

Two places in preprocess.py and META_scraper.py are applied with Singleton Pattern. Singleton pattern is a creational pattern that allows only one instance to exist and provides a single and global access point for this instance. Benefits: It prevents other objects from instantiating their own copies of the Singleton object, ensuring that all objects access the single instance so the security level may be improved. The number of the instance can be clearly shown, which is easier to manage in future maintenance.