Eeer in silenceOriginal: http://www.cnblogs.com/hebaichuanyeah/p/6091694.htmlIntent: Define a one-to-many dependency between objects so that an object is changed and other objects are updated.The Java event mechanism is an observer pattern, and when
Design PatternsSingle-Case modeDefinition: Ensure that a class has only one instance, and that it instantiates itself and provides this instance to the system as a whole.Description: You can only use the methods provided by the Singleton class to
I. OverviewIn software design work there is a dependency between objects, and when an object changes, all objects that depend on it need to be notified. If the design is not good, it is easy to cause the coupling between the object is too high,
Definition: Defines a one-to-many dependency between objects so that when each object changes state, all objects that depend on it are notified and updated automatically.Type: Behavior class pattern.Class Diagram:This is often required in software
PHP Observer design mode test code note
';}}/*** Observer 2 * Class SaveName */class SaveName implements Observer {public function update () {echo 'the name has been save';}}/*** Observer Interface * interface Observered */Interface Observered
Copy CodeThe code is as follows:
/**
* Viewer Mode
*
* Defines a one-to-many dependency between objects so that all objects that depend on it are notified and automatically refreshed when the state of an object changes
* Ability to conveniently
Introduced
The Observer pattern defines a one-to-many dependency on an object, so that when an object changes state, all its dependents are notified and updated automatically!
Design principles
In the Observer pattern, the state of the subject and
Definition:
Defines the one-to-many relationship between objects. In this way, when an object changes, all dependent persons will receive notifications and update automatically.
Keywords:
Observer: Observer
Subject: topic
1. What is the observer mode?
The observer pattern is a type of software design pattern. In this mode, a target object manages all observer objects that depend on it and actively sends notifications when its status changes.
2. Observer mode
The observer pattern separates the Observer (subscription) from the Observer (advertisement), implements the loose coupling of the code, and defines a one-to-many dependency, allowing multiple observer colleagues to listen to an observer, and at the
As the traffic lights change, the behavior of the car will change as well, and a traffic light can command multiple vehicles.In software systems, there is a relationship between some objects, such as traffic lights and cars, and a change in the
1 single-Case modeDefinition: Ensure that a class has only one instance and provides a global access point; Usage scenario: There are some objects we only need one, such as: thread pool, cache, dialog, registry object, log object, etc., if there are
Gof gives the definition :Define a one-to-many dependency between objects so if one object changes state, all its dependents is notified and Updated automatically.Defines a one-to-many dependency between objects so that when the state of an object
The Observer pattern defines a one-to-many dependency between objects, and when an object changes state, all of his dependents are notified and updated automatically;Define the theme, the function of the subject is to hold the observer's reference,
GnuhpcSource: http://www.cnblogs.com/gnuhpc/1. We need to understand the relationship between the newspaper, the subscription system and the Subscribe people, subscribe through the subscription system subscribe, once the newspaper has a new
This is the fifth article I wrote in PHP pattern design. The previous four articles in the continuous learning to deepen the understanding, to today again look at the Observer model, feel very easy to understand. This may be the result of our
1. What is an exception? What is the difference between an exception and an error?
1. Exception: program operation is not consistent with expectations, and errors are two different concepts!2. Throwing and catching exceptions3. Multiple catch
Copy CodeThe code is as follows:
/*** Viewer Mode** Defines a one-to-many dependency between objects so that all objects that depend on it are notified and automatically refreshed when the state of an object changes* Ability to conveniently
Design Pattern-Observer
Banqiao Renren http://www.jdon.com
Click here to attend monthly design model lectures
To a certain extent, Java will inevitably encounter the design pattern concept. Understanding the design pattern will give you a
Use MVC to develop Java applications
Download source code
【Author】: leequn1984 【size: 30 kb】【published on: 2005-12-16 」 browse: 98 〗
There is an article on the Internet
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.