Original articles, reproduced please be sure to put the following paragraph at the beginning of the article.This article is forwarded from Jason's Blog, the original link http://www.jasongj.com/design_pattern/observer/Observer pattern to introduce The Observer pattern definition
Observer mode is also called the Publish
In general, the definition of the observer pattern should be this: building a clean interface between the source of news that some object has changed and the Consumers O F that news.
The Observer pattern establishes a clean interface between the producer and the consumer of the message, thus making the coupling between the producer and the consumer of the message abstract. The
Observer mode:
The observer mode defines a one-to-many dependency, allowing multiple observer objects to listen to a topic object at the same time. When the status of this topic object changes, it notifies all observer objects so that they can automatically update themselves.
Abstract topic role: The topic
write two methods, such as flight methods, as shown below
public void Performfly () {flybehavior.fly ();}
So Ducks have their own flying behavior, we only need to instantiate the duck, such as in the constructor to initialize the corresponding flight and name of the specific class can be.
4. Third design principle: multi-use combination, less inheritance.
The above tells a design patternstrategy mode, and is a multiple-policy model, there are flight strategies, there is a name of the strategy,
One: What is the Observer pattern:Official definition: Defines a one-to-many dependency between objects. When the state of an object changes, all objects that depend on it are notified and automatically updated.For example, many people will subscribe to the weather forecast, and when the weather station gets tomorrow ( target object ), it will notify the person who subscribed to the weather forecast (the observer
On a blog with you to share the Android source of the decorator mode, a little meaning, today with you to share the viewer mode in Android, by the way, the observer mode and the relationship between the callback mechanism, welcome everyone to shoot bricks.Observer Pattern DefinitionThe Observer pattern defines a one-to-many dependency that allows multiple observer
Import java.util.Observable;
Import Java.util.Observer;
The/** Java API provides us with observer interfaces and observable classes to implement the so-called observer pattern.
The observable (Observer) class allows you to notify other objects (Implementation interface Observer,
The observer mode perfectly separates the observer from the observed object. For example, the user interface can act as an observer. business data is observed. The user interface observes changes in business data and displays the changes on the interface. One principle of object-oriented design is that every class in the system focuses on a certain function, rath
Ubiquitous Design Pattern in Android development-Observer PatternUbiquitous Design Pattern in Android development-Singleton pattern: ubiquitous Design Pattern in Android development-Builder Pattern
The Singleton mode and Builder mode are introduced earlier. For more information, see the two links above. This article focuses on the observer mode. Let's take a look at the definition of this mode.
Defines a
First, HTTP (WebService)
Progressive download based on HTTP progressive download streaming media playback is only based on the full download after the playback mode has made some minor improvements. Unlike download playback mode, which must wait for the entire file to be downloaded before it can begin playback, the incremental download client waits a short period of time to download and buffer the data in the front of the media file before it can beg
PrefaceLet's briefly talk about the definition and composition of the observer pattern.
The Observer pattern is set in relation to the compositionIn layman's terms, the Observer pattern defines a one-to-many dependency that allows multiple observer objects to simultaneously listen to a Subject object. When the subjec
The observer model is one of the more commonly used patterns and the basis for other common patterns, such as the MVC pattern, which is a model based on observer mode.
In the Java language, the implementation of observer mode is very simple, that is, let the observer inherit the observable class, and let the
The Design Observer pattern (Observer) perfectly separated the observer from the observed object. For example, the user interface can be used as an observer, the business data is observed, the user interface observes the changes in the business data, and when the data changes, it is displayed in the interface. One of t
Playing and downloading streaming media in iOS
Introduction to streaming media in iOS: A stream playing mode between downloading local playback and Real-Time Streaming Media. Downloading local playback must download all files before playing, incremental download does not have to wait until all the downloads are completed before playing the video. It can download
The observer mode is a mature mode for multiple objects to know data changes in an object. In the observer mode, there is an object called "theme" and several objects called "Observer". The relationship between "theme" and "Observer" is a one-to-many dependency.. When the status of the "topic" changes, all "observers"
Tag: Java logs this dependent for Code mode packThe observer pattern for Java design patternsHave always wanted to write a study of the Observer Pattern Summary no opportunity, today learning to block the principle of the queue to see in the implementation of the producer consumer when the notification mode, is the so-called observer mode, just by the way to tidy
The actors involved in the Observer pattern are:
Abstract theme (Subject) role: Abstract theme Roles Keep all references to observer objects in a cluster (such as a ArrayList object), each subject can have any number of observers. Abstract topics provide an interface for adding and removing observer objects, and abstract theme roles are also called abstract-
Intention:
Defines a one-to-many dependency between objects, and when the state of an object changes, all objects that depend on it are notified and automatically updated "GOF95"
Also known as publish-subscribe (publish-subscribe) mode, model-view (model-view) mode, source-monitor (Source-listener) mode, or dependent (dependents) mode
Structure Chart:
Main roles
Abstract theme (Subject) role: The theme role holds all references to the Observer
Intention:Defines a one-to-many dependency between objects, and when an object's state changes, all objects that depend on it are notified and automatically updated.Applicability:When an abstract model has two facets, one aspect depends on the other. The two are encapsulated in separate objects so that they can be individually changed and reused.When a change to an object needs to change other objects at the same time, it is not known how many objects need to be changed.When an object must notif
There have been a lot of online sharing and notes on the design model. I am still writing this article about nothing new. This is mainly to record my recent learning and life, in addition, I hope to use this blog post to restart my blog to fill my life. I haven't written anything for a long time. I have been watching my blog for a long time and looking back at the blank days of my memory, I felt a little scared. after such a long period of time, I did not even leave any trace. My existence was t
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.