|
In computer programming, event-driven programming or event-based programming is a programming paradigm in which the flow of the program is determined by sensor outputs or user actions (mouse clicks, key presses) or messages from other programs or threads. Image File history File links Merge-arrows. ...
Programming redirects here. ...
A programming paradigm is a fundamental style of computer programming. ...
Program flow is the path of execution through a computer program. ...
Not to be confused with censure, censer, or censor. ...
Operating a mechanical 1: Pulling the mouse turns the ball. ...
In computer science, message passing is a form of communication used in concurrent programming, parallel programming, object-oriented programming, and interprocess communication. ...
Event-driven programming can also be defined as an application architecture technique in which the application has a main loop which is clearly divided down to two sections: the first is event selection (or event detection), and the second is event handling. In embedded systems the same may be achieved using interrupts instead of a constantly running main loop; in that case the former portion of the architecture resides completely in hardware. In computing, the main loop (sometimes called the event loop or main event loop) is a common design approach, typically used by applications featuring an event driven graphical user interface. ...
In computing, an interrupt is an asynchronous signal from hardware or software indicating the need for attention. ...
Event-driven programs can be written in any language, although the task is easier in languages that provide high-level abstractions to support it. Some integrated development environments provide code generation assistants that automate the most repetitive tasks required for event handling. In computer science, abstraction is a mechanism and practice to reduce and factor out details so that one can focus on a few concepts at a time. ...
An integrated development environment (IDE), also known as integrated design environment and integrated debugging environment, is a programming environment that has been packaged as an application program,that assists computer programmers in developing software. ...
This article or section does not adequately cite its references or sources. ...
Contrast with batch programming In contrast, in batch programming, the flow is determined by the programmer. Although batch programming is the style taught in beginning programming classes, the more complex event-driven programming is the standard architecture of modern interactive programs. Here are two pseudocode versions of a trivial program to add two numbers: Pseudocode (derived from pseudo and code) is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but typically omits details that are not essential for the understanding of the algorithm, such as subroutines, variable declarations and system-specific...
Batch version read a number (from the keyboard) and store it in variable A[0] read a number (from the keyboard) and store it in variable A[1] print A[0]+A[1] Event-driven version set counter K to 0 repeat { if a number has been entered (from the keyboard) { store in A[K] and increment K if K equals 2 print A[0]+A[1] and reset K to 0 } } At first sight, the event-driven program seems more cumbersome and for such a trivial task is indeed so. However, the second program can be generalized far more easily than the first. Instead of checking just for a number entry we may add code to check whether any of several events has occurred. Then for each event we can execute a particular piece of code that is commonly referred to as an event handler. An event handler is a part of a computer program created to tell the program how to act in response to a specific event (e. ...
A slight variation in the above further illustrates the point: set counter K to 0 whenever a number has been entered (from the keyboard) { /* whenever a keyboard number event occurs */ store in A[K] and increment K if K equals 2 print A[0]+A[1] and reset K to 0 } } Example: reading from a socket This example uses pseudocode to illustrate how data is read from a socket using an event-driven approach: Pseudocode (derived from pseudo and code) is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but typically omits details that are not essential for the understanding of the algorithm, such as subroutines, variable declarations and system-specific...
A socket generally designates a cavity or region used for fitting and connecting some specific device. ...
function read_next_data(fd) data = read_async( fd ) if len(data) == 0 => Nothing to read, register to be called back when something is ready event_polling_register( fd, read_next_data ) => Go back to doing something else else => Data was available and len(data) was received add_data_to_buffer( buffer, data ) end_if end_function This example uses Tcl code to illustrate how data is read from a socket using an event-driven approach: Tcl (originally from Tool Command Language, but nonetheless conventionally rendered as Tcl rather than TCL; and pronounced tickle) is a scripting language created by John Ousterhout. ...
# open channel set chan [socket $host $port] set buffer "" fconfigure $chan -blocking none # register event handler fileevent $chan readable [list read_next_data $chan buffer] # process event until end of file proc read_next_data {chan bufferVar} { upvar #0 $bufferVar buffer append buffer [read $chan] if {[eof $chan]} {close $chan} } Event handlers Because the code for checking for events and the main loop do not depend on the application, many programming frameworks take care of their implementation and expect the user to provide only the code for the event handlers. In this simple example there may be a call to event handler called OnKeyEnter() that includes an argument with a string of characters, corresponding to what the user typed before hitting the ENTER key. If we want to add two numbers we need to use storage outside the event handler, so the implementation might look like this In computing, the main loop (sometimes called the event loop or main event loop) is a common design approach, typically used by applications featuring an event driven graphical user interface. ...
A trivial event handler declare globally the counter K and the integer T. OnKeyEnter(character string S) { convert S to a number N if K is zero store N in T and increment K otherwise add N to T, print the result and reset K to zero } Of course, using global variables is not a good idea and a better solution is to use object oriented programming making the event handler a method of an object that also holds the information necessary between calls to the event handler. In computer programming, a global variable is a variable that is accessible in every scope. ...
Object-oriented programming (OOP) is a computer programming paradigm in which a software system is modeled as a set of objects that interact with each other. ...
While keeping track of history is straightforward in a batch program, it requires special attention and planning in an event-driven program.
Creating event handlers The first step in developing an event-driven program is to write a series of subroutines, or methods, called event-handler routines. These routines handle the events that the main program will respond to. For example, in a GUI program, we might be interested in a single (as opposed to a double) left-button mouse-click on a command button. So a routine would be written to respond to such an event. The routine might open another window, save data to a database or exit the application. Many modern day programming environments provide the programmer with event templates so that the programmer need only supply the event code. In computer science, a subroutine (function, procedure, or subprogram) is a sequence of code which performs a specific task, as part of a larger program, and is grouped as one, or more, statement blocks; such code is sometimes collected into software libraries. ...
In object-oriented programming, the term method refers to a subroutine that is exclusively associated either with a class (called class methods, static methods, or factory methods) or with an object (called instance methods). ...
GUI redirects here. ...
This article is principally about managing and structuring the collections of data held on computers. ...
Binding event handlers The second step is to bind event handlers to events, so that the correct function is called when the event takes place. Graphical editors combine the first two steps: double-click on a button, and the editor creates an (empty) event handler associated with the user clicking the button and opens a text window so you can edit the event handler.
Main loop -
The third step in developing an event-driven program is to write the main loop: a function that checks for events, and then calls the matching event handler. Most event-driven programming environments already provide this main loop, so it need not be rewritten. In computing, the main loop (sometimes called the event loop or main event loop) is a common design approach, typically used by applications featuring an event driven graphical user interface. ...
In computing, the main loop (sometimes called the event loop or main event loop) is a common design approach, typically used by applications featuring an event driven graphical user interface. ...
Frameworks and libraries - Azuki framework's event-based processing
- Eiffel Event Library [1]
- Cocoa (API) & Objective-C, a reflective, object-oriented programming language which adds Smalltalk-style messaging to C.
- GLib
- Gui4Cli, an event-driven programming language for Windows
- Liboop, event loop management library [2]
- libsigc++, a callback framework for C++
- libevent, an event notification library for C/C++
- libasync, part of the sfs and sfslite libraries[3], is a very efficient event-based library for C++
- POE, Perl
- PRADO, a component-based and event-driven Web programming framework for PHP 5
- REBECA, Event-Based Electronic Commerce Architecture
- Tcl, Tcl language has event-driven programming built in
- Twisted, Python
- The Qt Toolkit, a cross-platform GUI toolkit for C++ based on an event-driven model. A version called Qt/Console exists which omits the GUI features, but still includes the event-handling framework and some other features like cross-platform networking, threading, and XML libraries.
- QP is a family of open source, event-driven frameworks for real-time embedded systems. QP goes several steps beyond the traditional real-time operating system RTOS, by providing a generic, reusable, even-driven infrastructure for executing concurrent tasks structured as hierarchical state machines. [4]
- jemula, the open-source event-driven simulation environment in JAVA
- esper, an open-source component for complex event processing
A Cocoa application being developed using Xcode. ...
Objective-C, often referred to as ObjC or more seldomly as Objective C or Obj-C, is an object oriented programming language implemented as an extension to C. It is used primarily on Mac OS X and GNUstep, two environments based on the OpenStep standard, and is the primary language...
Object-oriented programming (OOP) is a computer programming paradigm in which a software system is modeled as a set of objects that interact with each other. ...
A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ...
For other uses, see Small talk. ...
C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ...
GLib is a cross-platform utility library. ...
Various guis all running together. ...
Libsigc++ is a C++ librabry for typesafe callbacks. ...
For a discussion of callback with computer modems, see callback (telecommunications). ...
libevent is an asynchronous event notification library. ...
Programming Republic of Perl logo The Perl Object Environment or POE is a library of Perl modules written in the Perl programming language by Rocco Caputo et. ...
Prado may refer to: Land Cruiser Prado, a 4WD vehicle from Toyota Museo del Prado, an art gallery in Madrid Prado, Spain, a village in Castile-Leon the prado dam Prado River Miguelanxo Prado, a spanish comic book artist Ed Prado, a U.S. appeals court judge PRADO, a PHP...
Tcl (originally from Tool Command Language, but nonetheless conventionally rendered as Tcl rather than TCL; and pronounced tickle) is a scripting language created by John Ousterhout. ...
Twisted is an event-driven networking framework written in Python and licensed under the MIT licence. ...
For other uses, see Qt. ...
In computer programming, widget toolkits (or GUI toolkits) are sets of basic building elements for graphical user interfaces. ...
A Real Time Operating System or RTOS is an operating system that has been developed for real-time applications. ...
See also Signal programming is often used in the same sense as Event-driven programming. ...
A programming paradigm is a fundamental style of computer programming. ...
In electronics, a hardware description language or HDL is any language from a class of computer languages for formal description of electronic circuits. ...
It has been suggested that Complex Event Processing be merged into this article or section. ...
To meet Wikipedias quality standards, this article or section may require cleanup. ...
Publish/Subscribe (or pub/sub) is an asynchronous messaging paradigm where senders (publishers) of messages are not programmed to send their messages to specific receivers (subscribers). ...
Wikipedia does not have an article with this exact name. ...
This article is about the Visual Basic language shipping with Microsoft Visual Studio 6. ...
References - Grant Palmer: Java Event Handling, Prentice Hall, ISBN 0-13-041802-1.
- David Luckham: The Power of Events - An Introduction to Complex Event Processing in Distributed Enterprise Systems, Addison-Wesley, ISBN 0-201-72789-7.
- George S. Fishman: Discrete-Event Simulation - Modeling, Programming, and Analysis, Springer, ISBN 0-387-95160-1.
- Bertrand Meyer (2004): The power of abstraction, reuse and simplicity: an object-oriented library for event-driven design, in Festschrift in Honor of Ole-Johan Dahl, eds. Olaf Owe et al., Springer-Verlag, Lecture Notes in Computer Science 2635, also available online.
- Miro Samek: Practical Statecharts in C/C++: Quantum Programming for Embedded Systems, CMP Books, ISBN 1-57820-110-1.
- Faison, Ted (2006). Event-Based Programming: Taking Events to the Limit. Apress. ISBN 1-59059-643-9.
Grant H. Palmer (M.A., American history, Brigham Young University) is a three-time director of LDS Institutes of Religion in California and Utah, a former instructor at the Church College of New Zealand, and an LDS seminary teacher at two Utah locations. ...
Bertrand Meyer (born 1950 in France) developed the Eiffel programming language, and is an author, academic and consultant in the field of computer languages. ...
External links The Portland Pattern Repository (PPR) is the subdirectory c2. ...
Martin Fowler is a famous author and international speaker on software architecture, specializing in object-oriented analysis and design, UML, Patterns, and agile software development methodologies, including Extreme Programming. ...
Ben Watson is the name of several well-known people, including: Ben Watson (footballer), English football (soccer) player. ...
Christopher McDonald (born February 15, 1955 in New York City, New York, USA) is an American actor. ...
|