DEV Community

Mayank Koli
Mayank Koli

Posted on

Why Observer Pattern Sucks

While making games one of the most commonly used design pattern we see developers use is Observer pattern. Which on one hand is truly great when you look at it. I mean imagine instead of having your player communicate every single event with other objects in scene like health manager, sound manager you can have them individually subscribe to player and observe it. This way all your other components will be disconnected from each other and even if lets say one component stops functioning properly other will work just fine as long as player is working just fine.

So where's the problem. Well when you’re working on a game with a single player its good to work with observer pattern. But lets say you are making a app which contains cluster of mini games then you'll have to separately write the observer pattern code for them all. Which will in-turn increase the number of scripts. So that's where you got to make the decision if you want to let the number of files increase just to use observer pattern.

Top comments (0)