Even Driven Programming:
This is the process where the flow of the program is determined by certain events such as: * Senor output
* User actions i.e. mouse clicks, key presses
* Messages from other programs
As users we have come across event driven program every day when we use a computer i.e. navigating through our computer user interface, also whilst playing computer games. By clicking on the mouse the computer picks up the event that has been made by this action, same goes for when we play computer games. This is because the events driven program picks up the actions that have been carried out, reads it then gives an output. Event driven programming allows flexibility as it gives users full control whilst designing the program as they tell the program what it should do and at what time it should carry out the event. The key features of events driven program are: * Service oriented - this means everything illustrated on the screen provides a service to the user. * Time driven – this is where the event will only occur from the users input for example when they click on a button * Event handlers – this is when a code is activated when an event occurs for example when a user clicks on a print preview button, when the button is pressed the code that is linked to the button is activated and thus allows the event to occur thus bringing up the print preview page * Trigger functions – this is the same as the event handlers * Event – this is where the program is notified that something has happened for example when a user clicks a button on a keyboard. * Event loops – this is where the program checks for all possible events non-stop * Flexibility – due to flexibility making changes to event driven program will be easy, users tend to change their minds. * Ease of development – simplicity of programs means that events driven programs are easier to develop, maintain and amend. The disadvantages of event driven programs is the fact that they can be slow in terms of a lot of processing power is being used up by the need for event loops checking the GUI to find out if anything has happened.
For example below is an event driven program created to display random lottery numbers:
The buttons above each have a code behind them so that when they are clicked.
When the hide button is clicked,
The content on the form will be hidden as shown below:
This is because the code behind the button enables the program to hide the information that has been inputted. This is due to this code shown below,
When the program is compiled and the hide button is clicked, the event program will follow what the programmer has told it to do via this code thus hiding the information. This is the same as the show button when the program is compiled the event program will follow what it has been told to do by the programmer. So when the show button is clicked it will show the information that have been hidden by the hide button.
The lotto button does something different from the show and hide button, behind that button the code the programmer has used will enable the program to generate different and random numbers all due to this code below:
The software program I will be using to create is Microsoft visual C# 2010
The code above allows the program to generate random numbers then show then via labels and each time the user clicks the lotto button it generates new and different numbers. Below is a diagram of how the Calderdale train ticket program will look like:
I will enter information behind each function for example the departure and destination will be a combo box where I will put the train stations in order for the user to be able to select which station they want. I will also include a numeric up and down selection which will enable the user to choose how many passengers will be travelling. I will include a check box which will represent a return ticket,...
Please join StudyMode to read the full document