Difference between revisions of "Observer pattern"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(See also)
Line 36: Line 36:
  
 
* [https://en.wikipedia.org/wiki/Observer_pattern Observer pattern] @ Wikipedia
 
* [https://en.wikipedia.org/wiki/Observer_pattern Observer pattern] @ Wikipedia
 +
 +
[[Category:Computer science]]
 +
[[Category:Design]]
 +
[[Category:Design patterns]]
 +
[[Category:Software]]
 +
[[Category:Software design patterns]]
 +
[[Category:Software development]]

Revision as of 04:35, 21 April 2016

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

The Observer pattern is mainly used to implement distributed event handling systems.

It is also a key part in the model–view–controller (MVC) architectural pattern.

The observer pattern is implemented in numerous programming libraries and systems, including almost all GUI toolkits.

Memory leaks

The observer pattern can cause memory leaks, known as the lapsed listener problem.

The observer pattern requires both explicit registration and explicit deregistration (as in the dispose pattern), because the subject holds strong references to the observers, keeping them alive.

Leakage can be prevented by the subject holding weak references to the observers.

Related patterns

Related patterns include:

See also

External links