What are the advantages of the delegate pattern over the observer pattern?

Posted by JoJo on Programmers See other posts from Programmers or by JoJo
Published on 2012-12-02T00:06:55Z Indexed on 2012/12/02 5:21 UTC
Read the original article Hit count: 313

In the delegate pattern, only one object can directly listen to another object's events. In the observer pattern, any number of objects can listen to a particular object's events. When designing a class that needs to notify other object(s) of events, why would you ever use the delegate pattern over the observer pattern? I see the observer pattern as more flexible. You may only have one observer now, but a future design may require multiple observers.

© Programmers or respective owner

Related posts about design-patterns

Related posts about delegates