Singleton Design Pattern - SENG-350-2024-fall/Team-1 GitHub Wiki
Source: app/backend/app.py, Lines 32-24.
# Init queue - Singleton Design Pattern:
patientQ = pq.PatientQueue()
patientQ.build_queue_from_db()
The Singleton design pattern is used for the PatientQueue
in our system to ensure there is only one consistent instance of the queue accessible throughout the application. This single instance prevents the creation of multiple queues, which could lead to data inconsistency. By centralizing the queue, the system provides efficient resource management and ensures real-time updates are accessible to all components, such as healthcare staff and administrators. This implementation helps maintain accurate and up-to-date patient information in a resource-sensitive environment. Once the Singleton instance of PatientQueue
is created and initialized, the build_queue_from_db()
method is then called to populate PatientQueue
from the database.