I have have to design a "notification system" and I am running into a small design problem. I am having trouble knowing what design choice to make.
Here is what happening:
I have two classes SMTPNotifier and SQLNotifier. SMTPNotifier has the responsibility to send notifications via SMTP, as for SQLNotifier it has to save notifications to an SQL DB. They both implement the iNotifier (iNotifier.notify(notification) and iNotifier.notifyAll(List<notification>)) interface. I also implemented a controller/facade CTLNotification that have an attribute notifier:iNotifier because the controller does not need to know where the notifications are sent (via SMTP or SQL DB). And last of all, I have the dateNotification (oldDate:DateTime, newDate:DateTime, dateNotification.getDetails():String) and the PMNotification (oldPM:String, newPM:String, PMNotification.getDetails():String). dateNotification is created when a projects due date is changed and PMNotification is created when the project manager of a project is changed. They both inherit from the abstract class notification (timestamp:DateTime, projectID:Int, notification.toString():String-This use the template method pattern with the ChildClass.getDetails() implementation) and the previously mention controller CTLNotification posses a list of notification that it can pass to its iNotifier.
Now my problem is that each notification has a trigger (who triggered the creation of the notification) and a receiver (who should be notify).
Where do I implement this? Do I give my notification a trigger and a receiver attribute? Should I pass those as parameter to the iNotifier.notify() function? And what if a notification sent via SMTP needs its trigger and receiver to be email addresses and a notification sent to a SQL DB needs its trigger and receiver to be a simple ID (username or a unique number)?
Or maybe I should do something like: dateSMTPNotification, dateSQLNotification, PMSMTPNotification, PMSQLNotification.
But it seems to be adding more class than it should be to my design.
Aucun commentaire:
Enregistrer un commentaire