UNIT 14
P1 - Explain THE KEY FEATURES OF EVENT DRIVEN PROGRAMMING
Time driven
Time driven programming is a method of computer programming which is commonly used in
real-time computing. Where code execution is managed by the clock on the computer. A
program is split into specifc targets which requires to be activated regularly. The patern is
saved in a table which is dispatch able in which rules are applied to running the tasks on a
schedule.
Service orientated
Many networking sofware applications use techniques which are service-oriented so they are
able to be diferent applications are able to reuse code components. Departments in a business
can create and release services using diferent types of programming languages. In which other
sofware applications are able to gain an advantage from this service
Event handlers
Common programs have controls on them. Controls are objects on a form for example a list
box. A lot of event driven programming environments such as VB.NET have toolbox’s showing
objects which can be input to forms. Many objects have many possible events which could be
right click.
Trigger functonn
Events driven programming language have trigger functions to choose which event handler to
execute according to which event occurred. Every object has a range of trigger functions. All
objects have a range of trigger functions one for each event which can occur to the object.
When this control is created the programmer has to identify trigger functions otherwise no
properties or methods will be created for the control.
Events e.g. mouse events keyboard events form events
There are many events which can occur that can cause event handlers to trigger. For example a
mouse event can consist of: lef clicking double lef clicking right click and hovering. While as
keyboard can consist of: key press key down and key up. HTML object consists of clicking an
object. Form events consists of events which load and show for the frst period of time and
trigger event used when the form gains focus. Form events are able to trigger event handlers for
objects on a form such as an accept buton code for user uses the enter key buton on the form.
Event loops
, Event driven programming languages have event loops implemented within them at a standard
the programmer would not notice. The event loops are required to test user interface to identify
if anything has occurred. For example typing leters from the keyboard to a textbox.
When an event is detected the event will proceed to trigger functions which will look for the
appropriate event handler to run code in the program which is writen for that event.
Event driven programming languages usually have provision for programmers to develop event
listeners to improve the functions of the program and even more fexible. This is because it
would not be possible for designers of programming languages to provide events for every
possible circumstance.
Suitability for graphical interfaces
Event driven programs are reasonable for graphical user interfaces (GUIs) A GUI shows the user
many graphical choices and menus which can be used with input devices such as a keyboard.
An event driven programming language will use a GUI approach to allow users choice of variety
of controls. Every control has a specifc reaction to events with cost which is appropriate for
each event and the tasks of the program.
Many controls rely
Simplicity of programming
Event driven programming languages are able to make programming simple in comparison to
traditional fow driven languages. Due to the programming language being very visual.
A control for example a buton can easily be put on a form from the toolbox. When it appears
on the form the programmer is able to see it. The programmer can choose to see properties of
control when coding the program.
Ease of development
Program development is simple with an event driven language because the programmer
requires work on one event of an event of one control at a time.
Flow driven languages requires to be completed before it can be run and tested whiles an event
driven language is able to run with as litle as only the code for each event completed.
Testing is easy because each event is testes in turn.
, P2- Demonntrate the une of event driven tooln and
techniquen
Program 1 code
Public Class Form1
Dim WithEvents aTimer As New System.Windows.Forms.Timer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim num1 As Short 'maximum 32767, minimum –32768
Dim num2 As Integer 'maximum 2,147,483,647 minimum -2,147,483,648
Dim num3 As Single 'maximum 3.4028235E+38 , minimum -1.401298E-45
Dim num4 As Double ' -1.79769313486231570E+308 to -4.94065645841246544E-324 for
negative, 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive
Dim total As Integer
Dim average As Double
MessageBox.Show(average) 'When the button1 is clicked the program will perform
calculations from step by step instructions as set: adding num1, num2, num3, num4 and then
diving them by 4.
' Therefore this would be sequence programming.
End Sub
Private Sub aTimer_Tick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles aTimer.Tick
Timer.Text = DateTime.Now.ToString("MMMM dd, yyyy h:mm:ss tt")
End Sub
Private Sub Form1_Shown(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Shown
aTimer.Interval = 200
aTimer.Start()
End Sub
End Class
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller xeon. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for £10.49. You're not tied to anything after your purchase.