Louis I. answered 04/25/19
Computer Science Instructor/Tutor: Real World and Academia Experienced
Hmm, so trying to follow this based on the assignments notes.
Seems like the application / use case is as follows:
- a user's subscription to the election results is the covers the Observer Pattern part (Observer = the Subscriber, Subject = new election result update)
- the Subscriber's "State(s) of interest" is where the Strategy Pattern might be applied, although strictly speaking, I'm not sure I see the need for that pattern here ...
The Observer pattern part of this is fairly straightforward, right?
The "Subscribed User" object implements the "Listener" side of the Observer Pattern.
The "Election Stat" Object implements the "Subject" side of the Observer Pattern.
Where might the Strategy Pattern side of this fit in?
Presumably, "Subscribed User" is assigned "State(s) of Interest" when it's created (sometime before it subscribes for election-stat-update notifications).
So I'm thinking the "registerObserver()" method implementation on the Subject is smart enough to interrogate the Observer object for a "States of Interest" or a "Scope of Interest".
The implementation of the Subject's "updateAllObservers()" method would be "State-stat-update" aware - targeting registered Listener/Observers based on that "scope of interest" assigned to a given "Actionable Event".
I'm just not sure where "selecting 1 of multiple algorithms" comes into play, so I must be missing something ... just wanted to get a thread started around this.