Difference between revisions of "Observer pattern"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Created page with "The '''observer pattern''' is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them aut...")
 
Line 9: Line 9:
 
Related patterns:  
 
Related patterns:  
  
* [[Publish–subscribe pattern
+
* [[Publish–subscribe pattern]]
 
* [[Mediator pattern]]
 
* [[Mediator pattern]]
 
* [[Singleton pattern]]
 
* [[Singleton pattern]]
Line 15: Line 15:
 
== See also ==
 
== See also ==
  
* [[]]
+
* [[Software design pattern]]
  
 
== External links ==
 
== External links ==
  
 
* [https://en.wikipedia.org/wiki/Observer_pattern Observer pattern] @ Wikipedia
 
* [https://en.wikipedia.org/wiki/Observer_pattern Observer pattern] @ Wikipedia

Revision as of 11:43, 12 October 2015

The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.

Description

It is mainly used to implement distributed event handling systems. The Observer pattern is also a key part in the familiar model–view–controller (MVC) architectural pattern.[1] The observer pattern is implemented in numerous programming libraries and systems, including almost all GUI toolkits.

The observer pattern can cause memory leaks, known as the lapsed listener problem, because in basic implementation it requires both explicit registration and explicit deregistration, as in the dispose pattern, because the subject holds strong references to the observers, keeping them alive. This can be prevented by the subject holding weak references to the observers.

Related patterns:

See also

External links