The Observer pattern – advantages and disadvantages
The Observer pattern provides you with the following advantages:
It supports the principle of loose coupling between objects that interact with each other
It allows sending data to other objects effectively without any change in the
Subject
orObserver
classesObservers
can be added/removed at any point in time
The following are the disadvantages of the Observer pattern:
The Observer interface has to be implemented by
ConcreteObserver
, which involves inheritance. There is no option for composition, as the Observer interface can be instantiated.If not correctly implemented, the
Observer
can add complexity and lead to inadvertent performance issues.In software application, notifications can, at times, be undependable and result in race conditions or inconsistency.