Sabtu, 30 Juni 2018

Sponsored Links

What is Event Driven Architecture | How does EDA differ from ...
src: i.ytimg.com

In computer programming, event-driven programming is a programming paradigm in which program flow is determined by events such as user actions (mouse click, keystrokes), sensor output, or messages from other programs./thread. Event-based programming is the dominant paradigm used in graphical user interfaces and other applications (eg JavaScript web apps) that center on performing certain actions in response to user input. This also applies to programming for device drivers (eg P in the stack of USB device drivers).

In an event-driven app, there is usually a main loop that listens to an event, and then triggers a callback function when one of the events is detected. In the same embedded system can be achieved by using hardware interrupts instead of the main loop that keeps running. Event-driven programs can be written in any programming language, although the task is easier in languages ​​that provide high-level abstractions, such as closing.


Video Event-driven programming



Event handlers

Trivial handler

Since code for checking events and main loops is common among applications, many programming frameworks take care of their implementation and expect users to only provide code for event handlers. In this simple example there may be a call to an event handler named OnKeyEnter () which includes an argument with a string of characters, according to what the user typed before pressing the ENTER key. To add two numbers, storage outside the event handler must be used. The implementation may look like this.

While keeping track of history is very easy in batch programs, it requires special attention and planning in an event driven program.

Exception handler

In PL/I, although a program itself may not be dominated by the event, some abnormal events such as hardware errors, overflow or "program checks" may occur that may prevent further processing. Exception handlers can be provided by the "ON" statement on the caller (invisible) to provide a cleanup routine thereafter before termination, or to perform a recovery operation and return to the interrupted procedure.

Create event handlers

The first step in developing an event-driven program is to write a series of subroutines, or methods, called event-handler routines. This routine handles events that will be addressed by the main program. For example, one click of the left mouse button on the command button in the GUI program can trigger a routine that will open another window, save the data to the database or exit the application. Many modern programming environments provide programmers with event templates, which allow programmers to focus on writing event code.

The second step is to bind the event handler to the event so the correct function is called during the event. The graphic editor combines the first two steps: double-click on the button, and the editor creates the incident (empty) associated with the user clicking the button and opening the text window so you can edit the event handler.

The third step in developing an event-driven program is to write the main circle. This is a function that checks for the occurrence of an event, and then calls the appropriate event handler to process it. Most event-driven programming environments already provide this main loop, so there is no need to be specifically provided by the application programmer. RPG, IBM's early programming language, whose 1960 design concept is similar to the event-driven programming discussed above, provides the built-in main loop I/O (known as the "programming cycle") in which calculations respond accordingly 'indicators' (flags) defined earlier in the cycle.

Maps Event-driven programming



General use

Most development tools and existing GUI architectures rely on event-driven programming. The Java AWT framework processes all UI changes to a single thread, called an Event submission thread. Similarly, all UI updates in the Java JavaFX framework occur in the JavaFX Application Thread.

In addition, systems such as Node.js are also event-driven.

Unit 14 event driven programming College paper Academic Writing ...
src: seofiles.s3.amazonaws.com


Criticism

The design of programs that depend on the event-action model has been criticized, and it has been suggested that event-action models cause programmers to create errors, difficult to extend and too complex application code. The table-driven state machines have been recommended as viable alternatives. On the other hand, state machines that are driven by the tables themselves suffer significant weaknesses including the state explosive phenomenon.

What is event driven programming in Java? - YouTube
src: i.ytimg.com


Stackless threading

The event-driven approach is used in hardware description language. The thread context only requires CPU stacks while actively processing events, once the CPU can move to process other event-driven threads, allowing a large number of threads to handle. This is basically a finite state machine approach.

Task 1-Language Choice By Joshua Wild. - ppt video online download
src: slideplayer.com


See also

  • Autonomous peripheral operation
  • Comparison of programming paradigms
  • Data flow programming (similar concept)
  • DOM event
  • Event-driven architecture
  • Event stream processing (similar concept)
  • Hardware description language
  • Disrupt
  • Inversion control
  • Message-oriented middleware
  • Programming paradigm
  • Publish-subscription pattern
  • The reactor pattern
  • Signal programming (similar concept)
  • Architecture based on gradual incident (SEDA)
  • Time-triggered system (alternative architecture for computer systems)
  • Virtual synchronization, distributed execution model for event-driven programming

Event Driven Programming - The Fundamentals. - YouTube
src: i.ytimg.com


References


Python Programming: Event Driven Programming - YouTube
src: i.ytimg.com


External links

  • Presentation of concurrency patterns is given in scaleconf
  • Events-Based Programming: Introduction, Tutorials, History, tutorial by Stephen Ferg
  • Event Oriented Programming, tutorial by Alan Gauld
  • Event Collaboration, articles by Martin Fowler
  • Rethinking Swing Threading, article by Jonathan Simon
  • Events-driven programming style, article by Chris McDonald
  • Event Based Programming using Template Specializations, articles by Christopher Diggins
  • Vista Concepts and Architectures - Multiparadigma Programming Environment, articles by Stefan Schiffer and Joachim Hans FrÃÆ'¶hlich
  • Programming and Event-Driven Agencies, chapters
  • LabWindows/CVI Resources
  • Distributed Publish/Subscribe Event System, an open source example produced at MSN.com and Microsoft.com

Source of the article : Wikipedia

Comments
0 Comments