Event Driven Programming

Download Report

Transcript Event Driven Programming

Key Features
WHAT IS EVENT DRIVEN PROGRAMMING?
EVENT DRIVEN PROGRAMMING IS WHERE A PROGRAMMING
PARADIGM WHICH CONTROLS THE FLOW OF A PROGRAM IS
MADE BY A FACTOR OF THINGS THIS RANGES FROM SENSOR
OUTPUTS TO MOUSE CLICKS AND KEY PRESSES.
EVENT HANDLERS
‘ARE CODE STATEMENTS THAT RUN WHEN AN EVENT OCCURS’
•
An event handler can be known as a of a program that activates after a certain event
has been triggered. For example, if the user uses the mouse by clicking something on
the screen, the computer will then process the command and tell the code to run.
This only works when the button has been clicked therefore if you click the same
button again the same piece of code will run a second time.
•
Event handlers can sometimes be what is known as a subroutine. To be able to work
the event handler must get information on the event it is trying to accomplish. This
would then be given to the event handler where it will be used to run a certain piece
of code. As an example, if the user uses the mouse to click something the event
handler will try to determine what it was actually used for to give an appropriate
response.
TRIGGER FUNCTIONS
•
Most of the language will use trigger functions this decides which event handler has to
be used for that task. Each individual object has its own fine-tuned range of trigger
functions, a substantial amount of objects use a trigger function for an individual event.
Visual basic allows a programmer to create separate controls for programs (from the
same origin). This lets the programmer get full control over a program. When making
such a clear control trigger, functions have to be clear so that it to can operate correctly.
Therefore, there will be no properties or ways of doing things for that particular control.
Certain lines of code are made for separate properties. Each material can be accessed by
the control and a set arrangement is used for properties which are capable to be
changed by the programmer afterward or on a later occasion.
EVENTS
‘ARE ACTIONS SUCH AS A FORM LOADING OR THE USER CLICKING THEIR MOUSE’
There are many types of events that can cause event handler to run. Some of these would
be mouse events for example clicking your mouse left clicking double click and hover.
These are all controlled though event handler. Another example would be the keyboard
this would include things like pressing keys and knowing when the keys come up. Form
events can trigger event handler for example pressing a button on the form. User interface
events are anything that the user does regarding user input when within a GUI based
operating system or onto the form of a program that is running within the computer.
EVENT LOOPS
‘ARE BUILT INTO THE OPERATING ENVIRONMENT TO KEEP CHECKING TO FIND OUT IF AN EVENT HAS OCCURRED’
•
The event loop is a type of programming code that waits for and gives events and
messages inside of a program. It works by asking some internal and external event
providers. These usually block the request until the actual event has arrived. Once this
has happened it gets the relevant event handler which dispatches the event. The event
loop works asynchronously with the message originator.
•
Due to the use of GUI most applications use event loops. This could be done with a
get_next_message () command. The program will block the command until there is
something for it to process.
FORMS
‘ARE USED TO CONTAIN OBJECTS WHICH EXPERIENCE EVENTS’
•
Forms perform a major part in most of the event driven programming environments as
this is what the user will see when the program runs. Forms are used to house all the
controls that the programmer used to design the program. Forms can also be a type of
control this could include a collection of events that can be used by the programmer.
Form events are a very powerful way of controlling a program as they can be used to
load the program and end it. There a re two types of form events these would be load
and activated. Load occurs when the form us first used. The load event is useful for
some parts of the code that will need to set variables and create settings this only needs
to be done one. Activated is a event which is used every time the form is opened. This
type of event is useful for updating the form and when the user returns to the form
from another form. A program might get information of another form when entering
details for a sale. When you return to the main form the event could bring up the
summary on the main form.
SERVICE ORIENTED
‘ARE USED TO ALLOW DIFFERENT APPLICATIONS TO REUSE CODE’
•
Service oriented code allows for the use to reuse the code. This is a great way to make
and design new software as it will save time you wont have to write it from scratch.
This could help in the future of programming because if all code was reusable code
writers would have to write as much. However writing reusable code can be a lot
harder than writing code it also takes longer to write. Service oriented programming is
a type of programming paradigm that is used in integrated business applications and
even critical software programs. Service orientated programming uses use of all
existing languages and platforms which is why it is so hard to write. These programs
are very sophisticated with well defined task with well defined input and output data
structures.
TIME DRIVEN
‘WHERE CODE EXECUTION IS CONTROL BY THE COMPUTERS CLOCK’
•
This is a piece of code that uses the time from the computer. This means that
something will run at a certain time. A good example of where this will be used is the
backup of your computer systems. This is because you can set it to run at a certain time
(10:00) on a certain day of the week (Friday). Then every week at 10:00 on a Friday
your computer will back its self up automatically without you doing anything. This is
what time driven means. These are used all the time inside computers especially for
automated services. Another example is when something needs activating by a certain
day. When the clock gets to the day that it needs to be activated by. The program will
stop working until you activate it this is also time driven.