samedi 14 septembre 2019

Can a [GoF]-subject override the notify method?

I'm modelling a situation in wich there are:

  • NotificationBox: the observer
  • list1, list2, list3: the subjects

now I would make a piece of diagram in wich using observer pattern describe the fact that each list implement different type of notify() (for example some change in the state of a list need to be notified only to some observer, with some criterion)

I made something like:

image

in this case each subject override the notify method in order to notify only some subset of observer depend on some criterion, and for using the correct update method.

Example

ListaMDDpubblico is a list composed by some file, each file have a specific tag. When a file is loaded, only the notificationBox associated at the user that "like" the tag of the file should be notified by using updateMDD.

It is [GoF]-friendly?

Or I need to make 3 different Subject abstract class, each implement the notify method in the list-way?

Thank's in advance

Aucun commentaire:

Enregistrer un commentaire