I read a book about the observer pattern. He gives the following example:
Class clockusing methodtime()
The class messagethat inherits from it 3 classes: Fax, Mail, Memo.
The app wants to send a message when 12AM arrives.
The book recommends the observer pattern. It says that if we add a new class: VideoMsgthat extends the message, this will affect the implementation of the Clock class. But I did not understand why. The Clock class will contain a collection of the object message, and if we add a new inherit class, it will not change the clock class.
I would appreciate if someone would explain the above example or give a better example.
source
share