Design Patterns - SENG-350-2024-fall/Team4 GitHub Wiki

State

State is a design pattern where the actions available to the system can only be performed conditional to some current program state. In Mister Ed, this will manifest in how different user groups are handled. Actions performable by the system will need to check whether the current user group (not logged in, standard user, medical staff, and admin) is permitted to perform the action, and then execute the action only if permissions are available.

Singleton

The singleton design pattern ensures that only one instance of a class is available at any given time. This allows for strict control over shared resources such as a database. In the case of the Mister Ed system, only a single instance of the VirtualTriage class should exist for each user. Since this class will be accessing the illness database to perform assessments, a singleton design pattern is ideal. To accomplish this, the back end triage class will be called only when the "Submit" button has been pressed on the triage page.

Decorator

The Decorator pattern adds specific features to individual objects dynamically, without altering the core class. In Mister Ed, this could enhance user roles (e.g., standard user, medical staff, admin) by dynamically adding functionalities like priority access or extended data views. When a user logs in, Mister Ed applies the appropriate decorator based on their role, allowing easy extension of permissions and features without modifying existing classes.

Chain of Responsibility

The Chain of Responsibility pattern delegates a request along a chain of handlers until one can process it. In Mister Ed, this is used for triage requests, where the system sequentially checks patient conditions. For instance, basic symptoms might be assessed first to recommend self-care, then more advanced handlers determine if an in-person visit or ED admission is necessary. This approach allows Mister Ed to process triage requests with flexibility, only escalating cases when required.

Facade

The Facade pattern provides a simplified interface to a complex system, allowing components to interact with various subsystems through a single unified interface. In Mister Ed, the Facade pattern simplifies interactions for the user interface by centralizing access to functionalities such as patient data management, notification services, and ED resource monitoring. For instance, when the nurse needs to review patient triage results, check ED resource availability, or notify a patient, the SystemFacade class provides these actions through a single entry point, reducing direct dependencies on multiple backend systems.