framework.First, we define an abstract observer./** * TODO (Description class Responsibilities) * @author Chao.gao * @date November 30, 2015 Morning 8:50:59 * @version /***aclasscanimplementtheSpecific observers:public class Endprocessmailsenthandler implements baseobserverhandler{//actual Update method, specifically implemented slightly}in observer mode, the target role is called by the client program and notifies the specific observer role through the target role. In the traditional observer
voidNotifyobserver () {//TODO auto-generated Method Stub for(Observer o:list) {o.update ("Hello, world!."); } }}The following code is specific to the observer implementation: Package Obeserver; Public class Implements Observer { @Override publicvoid update (String str) { // TODO auto-generated method stub System.out.println (str);} }Write a test code below to see: PackageObeserver; Public classObservertest { Public Static voidMain (string[] args) {Subject S1
registered, back Group is notify) 2, there is a better understanding, when one thing is done, you can do other things. such as: With Money can buy food, wear, drink. (One-to-many). When you spend money in the bank will be, SMS notify you, email notify you, notify you, you can also cancel SMS notification. What are the points of note when using Observer mode? If there is a cyclic dependency between the observers, the observed will trigger a cyclic call between them, causing the system to crash.
functions, because different observers have different ways, so declare them as pure virtual functions, implemented in derived classes.3. The observer is implemented with the list template in Std, so a destructor is required to release it.Viewer Interface Description:1. Because all observers have an update status, declare it as an interface.The 2.Update () function has different behavior for different concrete objects, so it is implemented in derived classes and declared as pure virtual function
hang a QQ on the computer, and then hang one on the phone, when we receive a friend message, our mobile phone and QQ on the computer will also receive the same message notification, which is actually the typical use of the observer pattern, at this time the message is an observer of the notification event, And the mobile phone and the computer side is an observer object, of course, the situation here is slightly more complex, need to match the message sender and receiver of the object, decide w
This is a simple image Viewer built with CSS + JS. You can click a thumbnail to view the large image. The description of each image is displayed. The position of the large image is fixed width and height, and the excess part is hidden, click the big picture to view the full size, compatibility: IE, Firefox, and Opera.
JS Section
Function showPic (whichpic ){If (document. getElementById ){Document. getElementById ('holder'). src = whichpic. href;If (wh
Software Introduction:This utility displays detailed information about all of the Winsock service providers installed on your system. For each Winsock service, the following information is displayed: Display name, enable/disable state, DLL type (32-bit or 64-bit), and creation/modification time. Winsockservicesview also allows you to easily disable/enable a Winsock service provider.Picture preview::http://dickmoore.cn/Down/winsockservicesview.zipWinsockservicesview (Sock Service
files as required, and it calls the Tinyxpath module to perform custom XPath syntaxCreate model constructs the read content as an objectThe class diagram for layout is as followsLine lines, including starting and ending pointsRectangle Rectangle, containing center point, width, heightScxmllayout contains all the rectangles and lines of data and has a way to calculate the entire layout of the graphicLayout sequence diagramAccording to Scxml object, execute layout algorithm, generate graph inform
The observer pattern in 23 kinds of software design patterns is also a kind of design pattern used in software development. In Apple development, the Apple Cocoa Framework has implemented this design pattern for us, that is, notification and KVO (Key-value observing), this post will first explain the common methods of notification and KVO and use examples, and then explain the observer pattern and the implementation of the Observer pattern, Finally, a self-fulfilling cocoa framework kvo.Article
) - Paper.subscribe (joe.drinkcoffee); inPaper.subscribe (Joe.sundayprenap, ' monthly ')); the //that is, Joe provides a method that can be called for the default "any" event, while another method that can be called is used when an event of type "monthly" occurs. Now let's trigger some events: thePaper.daily ();//Just Readbig News Today AboutPaper.daily ();//Just Readbig News Today thePaper.monthly ();//About to fall asleep reading thisinteresting analysis thePaper.monthly ();//About to
1. Content ViewerDoes not belong to the four components, only the content provider ContentProvider corresponding small function.If the contents of the database are found to be changed, they will be observed immediately.Here is the logical diagram:When the data inside the bank in a application changes, the A application sends the data to a piece of public memory, and the memory watcher reads the data in the public memory. So that the database of a application is changed.This mechanism is similar
yjviewcontroller.m//07-scrollview-View large image////Created by Jacky-mac on 15-6-17.//Copyright (c) 2015 www.train.com. All rights reserved.//#import "YJViewController.h" @interface Yjviewcontroller () iOS Learning-ScrollView (Image Viewer)
program to the simulator, as follows:To add a contact to the system contact, send a text message to this contact, as follows:Observe the Logcat print log as follows:09-15 07:42:33.109:i/system.out (644): The SMS database has changed.09-15 07:42:34.739:i/system.out (644): The SMS database has changed.09-15 07:42:35.189:i/system.out (644): The SMS database has changed.We enter a text message sent, will print three logs, that is, the onchange () method was called 3 times, that is, the database cha
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.