Which pattern did you choose?
Observer Pattern
Why did you choose each pattern? (Justify your use of it).
The primary objectuve of the Observer Patters is so that when one object changes state, all its dependents are notified and updated automatically.
In my case the Observers are UI elements that subscribe to the Player.
When the Player performs specified conditions (like pick ups), the subject notifies all observers at once and Observer.cs defines handlers for observer behavior.
The benifits of this are:
- New observers are easy to implement (scalable)
- Decoupling of Subject and Observers
- Reusability of observers
- Real-time updates
Draw the class diagram for your pattern(s):
Based off
Would something else have worked as well or better than this pattern?
When would be a bad time to use this pattern? (Dr. BC Note: This section could be better)
Since Unity does a lot of this functionality for you in different ways, for consistency in a large organization I would probably have used the Unity approach if that was the standard in my organization.
However, there are some issues with the Unity approach:
- Unity notifies observers in random order. Doing this myself gave me control.
- I was also able to reduce the overhead since I did not have to notify every observer every call
- With decoupling comes complexity