KEMBAR78
Event-Driven Programming | PDF | Computer Programming | Computer Program
0% found this document useful (0 votes)
14 views4 pages

Event-Driven Programming

Event-driven programming is based on the use of events to determine the control flow of a program. Events can be user actions, messages from other programs, or other occurrences, and each event triggers a specific event handler function. This approach separates the event processing logic from the rest of the code and is supported by many programming languages. Common examples include text editors, spreadsheets, and messaging systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Event-Driven Programming

Event-driven programming is based on the use of events to determine the control flow of a program. Events can be user actions, messages from other programs, or other occurrences, and each event triggers a specific event handler function. This approach separates the event processing logic from the rest of the code and is supported by many programming languages. Common examples include text editors, spreadsheets, and messaging systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Event-driven programming: characteristics, examples, advantages,

applications.
Event-driven programming refers to a programming model of
computers, where events that occur are used for determining the flow
of a program control.

It is not a type of technology or programming language, but an approach that is


implemented during the product development stage. Basically, it separates the logic
event processing of the rest of the code of a program.

This type of programming is designed to discover events as they happen.


happening, using an appropriate event handling procedure to deal with them,
usually through a call to a function or method.

Theoretically, the style of this programming is compatible with all languages of


programming, although it may differ in the way it is implemented.

In general, in an event-driven application there is a main loop that


"listen" for incoming new events, triggering a call to a function when
these are detected. Therefore, its operation focuses on events, deciding
these to execute and in what order.

Characteristics of event-driven programming

Event dependency
The flow of the program is determined by events that can be actions of the user,
messages from other programs, etc., separating the logic of event processing
from the rest of the program's code, thus contrasting with batch processing.

The events themselves can be to accept or reject a loan request,


called high-level event, until a user presses a key, which is a
low-level event.

Service-oriented
It is used to write programs designed for service without slowing down the
computer, since the service-oriented approach only consumes a little power
processing. In addition, services generally run in the background of
operating system.

Events
It is a condition that arises during the execution of a program and that requires some
action by the system. Each event is different by nature, some require
that the program recovers and displays certain information, and others that are initiated
calculations and changes of state.

The events include the mouse, the keyboard, a user interface, and the actions that are
must activate in the program when they occur. This means that the user must
interact with an object in the program, such as clicking a mouse button, use
the keyboard to select a button, etc.

Event controller
It is a specific unit of the program that is activated to respond to an event.
That is to say, it is a type of function or method that performs a specific action when it
activate a certain event.

For example, it could be a button that when the user clicks on it shows a
message and when I click that button again, close the message.

Activation functions
They are functions that decide which code to execute when a specific event occurs.
They are used to select which event handler to use when an event occurs.

Controlled time
It is a specific code that runs at a certain time. This means that
it is a predefined task to be done.

The Windows update is an example of controlled time, where the user


You can set when to update or when to check and download the update.

Examples of event-driven programming


Event-driven programs have become very common. Among the
notable examples include word processing, drawing tools,
spreadsheets, etc.

Most modern messaging systems also follow the oriented pattern.


to events, while large-scale websites use scalable architectures and
controlled by events of a distributed nature. Other examples are:

A key has been pressed (text editor).

A new task calendar is ready to be distributed to all staff.


(management system).

An HTML message has been received (web server).


An illegal trade pattern has been detected (fraud detection).

A car in a computer game crashes into another car (game of


careers).

A robot has arrived at its destination (real-time warehouse management).

Work permit
A practical example of an event used in event-driven programming
could be an employee requesting a work permit in a system. When this
the employee submits their application, it will trigger a notification that will be sent to the manager to
that it be approved.

The manager could see the details of the request, approve it or reject it, updating itself.
in the system without the need to log in again.

Start of actions
The actions of a program that follows the principles of object-oriented programming
events are initiated by events:

– From the hardware.

Scheduled.

Runtime.

From the operating system.

Activated by user instructions given through interaction with the GUI


of the program.

In its simplest form, programmers have to answer the following question:


What should happen when a certain event occurs?

The following pseudocode routine shows how a scheduler could work


Very simple. It consists of a main loop that runs continuously until it
produce some termination condition.

When an event occurs, the planner must determine the type of event and
select an appropriate event handler, or handle the event if one does not exist
appropriate event handler.

You might also like