Skip to content

Conversation

@FrankX-xzh
Copy link

Why I made the specific design decision:
I apply a singleton pattern in the SUD to ensure the LocationService of each data-source has at most one instance and provide a global access point to that instance to avoid bugs arising from multiple instances. And the singleton pattern can ensure only one instance to save memory which can improve software performance. So I chose the singleton pattern.
How I applied the new design:
I used the decorator to implement the singleton pattern in app\services\location_init_.py. Define a dictionary in the decorator to hold instances. Then every time create an instance, check it in the dictionary. If it has already instantiated, take the instance directly. If not, create an instance and store it in the dictionary. Then add “@singleton” to LocationService class to ensure each data-source has at most one instance.

@Kilo59 Kilo59 closed this Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants