Event Driven Complete
-
Upload
anamariana10 -
Category
Documents
-
view
223 -
download
1
description
Transcript of Event Driven Complete
![Page 1: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/1.jpg)
EVENT DRIVEN PROGRAMMING
NUR ATHIRAH BINTI MIMOL D20111048162
NURUL SYUHADA BINTI MAZLINA D20111048161
NOR SUHAIBAH BT ABDUL WAHAD@WAHAB D20111048212
NORSHAFILAH BINTI RAMLI D20111048176
NOR HAFIZA BINTI UTHMAN D20112052115
![Page 2: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/2.jpg)
Event driven programming
• is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or messages from other programs/threads.
![Page 3: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/3.jpg)
• Event-driven programming is the dominant paradigm used in graphical user interfaces (GUI) and other applications (e.g. Javascript web applications) that are centered around performing certain actions in response to user input.
![Page 4: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/4.jpg)
Purpose
![Page 5: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/5.jpg)
PurposeWith the development of a program with a graphical user interface (GUI) normally you want something to happen when the user performs certain actions, for example:Clicking on an area of the interface using the mousePressing a labelled buttonEntering text into a text field
![Page 6: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/6.jpg)
• In each of these cases, a program 'event' occurs, and the program can be designed to incorporate specific actions that would occur when different events occur. This type of program is referred to as an event-driven program.
![Page 7: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/7.jpg)
• In event-driven programs, the program is said to run in a 'main loop', referred to as an event loop.
• When some user input occurs, then the program responds appropriately. The program will be in one state prior to the event occurring, and will usually be in a different state after the program has responded to the event.
![Page 8: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/8.jpg)
Characteristics of event driven programming
• Can be written in any programming languages
• Event-driven approach contrasts with batch processing. Because
event-driven programming is an approach rather than a type of
language, event-driven apps can be created in any programming
language.
• Event-driven processing can improve responsiveness, throughput
and flexibility.
• Events are generally referenced, indexed, or named based on an
object (noun) and the type of action that triggered the event. For
example, "icon3_click" or "icon3 - onClick". Thus, they usually have
at least two "keys" (in an informal sense).
![Page 9: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/9.jpg)
• The task is easier in languages that provide
high-level abstractions.
• Windows-based applications or programs are being
regard as event-driven. For example, when the end
user chooses menu items, clicks the mouse and move
objects on the screen.
• With the advent of the World Wide Web (WWW),
event-driven programming has gained in popularity as
a way to add interaction to web pages.
![Page 10: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/10.jpg)
Example : Event handler Refer to application responds to the
events which executing particular code
for each type of event.
Input Come from event sources.
Source of an event Modeled as an object
Example: button click’s object is a button.
Type of the event Example : ActionEvent, WindowEvent,
MouseEvent
ActionEvent: passed to application which
contain info about the action.
![Page 11: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/11.jpg)
Differences with other programming
![Page 12: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/12.jpg)
![Page 13: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/13.jpg)
![Page 14: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/14.jpg)
Advantages
It allows for more interactive programs It allows sensors and other hardware to easily interact with software It can be implemented using hardware interrupts, which will reduce the power used by the computer Flexibility Very user friendly and highly interactive systems The lack of concurrent data access
![Page 15: Event Driven Complete](https://reader031.fdocuments.net/reader031/viewer/2022020312/577cc7931a28aba711a15f1c/html5/thumbnails/15.jpg)
Disadvantages Event-Driven Programming
• Event Driven Programming is often more complex and cumbersome than batch programming
• The flow of the program is usually less logical and obvious
• Classes are often not reusable or hard implement in other applications
• Generally only useful in GUI programming• Is often not portable to other operating system, such
as in the case .NET framework under windows that uses event driven programming