Colon classroom § 3. 4: event-driven

Source: Internet
Author: User

From: http://blog.zhenghui.org/2009/09/11/colon-class-3_4/

3.4 event-driven: I want to call you something. Don't bother me.

 

 

! Preview
    • Both of them make the caller no longer dependent on the calledCodeAsynchronous calls decouple the two from time.

    • The theme of them (control inversion, dependency inversion, and dependency injection) is control and dependency. The purpose is to decouple them, and the method is reverse. The key to achieving this is abstract interfaces.

    • The "Callback" emphasizes the behavior mode-the lower-layer reverse adjustment of the high-level layer, and the "abstract interface" emphasizes the implementation mode-precisely because the interface is abstract, the lower layer can call it without worrying about the specific details of the higher layer, so as to implement control inversion.

    • Inversion of control leads to passive event-driven programming

    • Event-driven behaviors are asynchronous, which is determined by the unpredictability and randomness of events.

    • Independence is the premise of Asynchronization, and time consumption is the reason for Asynchronization

    • The distribution/subscription mode is the alias of the observer mode. On the one hand, it can be seen as a simplified or degraded event drive, and on the other hand, it can be seen as the core idea of event drive.

? Question
    • What is an event? What types of events are there?

    • What is a callback function? What is asynchronous simultaneous calls? What are their functions?

    • What is the purpose of control reversal? How is it implemented? What role does it play in framework design?

    • What are the commonalities of control reversal, dependency reversal, and dependency injection?

    • What are the key steps for event-driven programming?

    • What are the characteristics and functions of asynchronous processes?

    • What are the most important features of event-driven programming? How are they implemented?

    • What is the relationship between event-driven and observer mode and MVC Architecture?

: Explanation

The comma gradually increases sleep and begins to close his head. During the game, I suddenly felt a cool waist. The blind eyes were blinded by the quotation marks. When I looked up and looked at myself with a burning eye on the podium, my cheeks were slightly hot and said, "Sorry, I slept too late last night ."

The colon does not agree: "I am worried that I cannot find a new topic. You have inspired me. There are three ways to go to bed in class --"

Voice was not lost, and some people laughed.

"The first is alert: If you want to go to bed, you may be worried about being discovered by the Teacher. From time to time, you can open your eyes and check the changes around you. At the same time, both ears remain vigilant and immediately stand straight when there is a change ." "The second kind is a wide-hearted style: a drop-down table to sleep, such as in an unattended environment. The highest person in the realm may not be able to fight, or be able to snoring ."

"In short, it's a lot of people ." The exclamation point's new online voice once again aroused laughter.

Continue analysis with the colon: "The third type is trust: Ask for a whistle, do not worry. Then there is no scrubs. you can hide your eyes and ears, and rest assured that you can go to bed. Which method would you like to use ?"

"The first way is to stay asleep. Most people who dare to use the second method are heartless. It is estimated that they cannot reach that level. As long as there is a companion, I think everyone will choose the third method ." The answer at the end of the period is unanimously recognized.

The colon continued: "Well, let alone the second method. Why is the third method superior to the first one ?"

Conclusion: "A sleepy person must not only have to nap but also be vigilant. It would be a great pleasure to entrust the alert task to a companion with a division of labor and cooperation ."

"How did they work together ?"

"Once a Leader finds a situation, immediately notify the target person to take action ." The full stop is colorful.

Apart from the embarrassment of the two parties, the other parties are not supported.

Seeing that the time is ripe, the colon is no longer circled: "alert-type personTake the initiativeRound Robin(Polling), the behavior depends on its own observation and judgment, isProcess-driven, In line with the conventional flow-driven programming (flow-driven programming) mode. Trusted usersPassiveNotification(Notification), behavior depends on external emergencies, yesEvent-drivenEvent-driven programming (EDP. Let's talk about this programming paradigm ."

The comma whispered: "I didn't expect a paradigm for dozing off ."

The colon glanced at him and continued: "to do the same thing, you can either adopt process-driven or event-driven. In my life, this is a simple example. Just now, the comma demonstrated one for everyone. Who can cite other examples ?"

As an example of an exclamation point: "When dealing with customers, the salesman calls or visits the door. His work is flow-driven. When the operator waits for a call, his work is event-driven ."

The question mark also says: "It is also a means of transportation. Buses are mainly process-driven and their routes have been pre-set. Taxis are mainly event-driven, its route is basically determined by the random passengers."

Using quotes as an example: "to buy a favorite magazine, you can choose to frequently patronize the newsstand, or you can choose to subscribe to it once. You can browse the news websites or blogs you are interested in. You can directly access the websites or subscribe to the corresponding RSS. Actively check whether updates are process-driven and event-driven by subscription ."

"A lot of work in windows can be processed in batches in DOS.ProgramImplementation can also be completed in the graphic interface. The former does not require manual intervention, and is obviously process-driven. The latter is undoubtedly event-driven ."

"It seems that you are familiar with this paradigm. However, although simple, it has infinite power. It seems like a trick, but in fact it's just a thousand moves. The subtlety of the break can be explained temporarily ." The colon enters the martial arts world without knowing it.

When everyone heard this, I was skeptical that I had to say something too much.

"The first question is: what is an event? In layman's terms, it is a matter of concern that has already occurred. In software, it generally represents a change in the state of certain information of a program. Event-driven systems generally provide two types of built-in events: low-level events or native events ), in a GUI system, such events are directly triggered by the mouse, keyboard, and other hardware devices. The other is a semantic event, which generally represents the user's behavior logic, is a combination of several underlying events. For example, the drag-and-drop operation mostly indicates moving the dragged object, which consists of three underlying events: Mouse pressing, mouse moving, and mouse releasing ."

Question mark: "Should programmers still be able to create new types of events ?"

"That is of course ." "There is also a type of user-defined event (User-Defined event ). They can be packaged based on the original built-in events, or virtual events ). In addition, programmers can not only define events, but also generate events. Although most events are natural events triggered by the outside world, sometimes programmers need to take the initiative to stimulate some events, such as simulating users' mouse clicks or keyboard input, this type of event is called a synthesis event [1]. These have further enriched and improved the Event System and event mechanism, making event-driven programming more penetrating ."

The exclamation point muttered: "It seems that there is still some name here ."

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.