Tuesday 18 November 2014

Key Features of Event Driven Programs.

Event Driven Paradigm

 Event-driven programming is a programming paradigm which is used when events occur. These events are usually from the user, such as mouse clicks and keyboard clicks. The paradigm makes it easy for the programmer to code the applications as there are two stages to every section of the code, the event that has happened and the action that happens when the event occurs. Once they have coded one section of code to make one event and action happen, they can easily move onto coding the next section.

Examples of event-driven languages

One example of an event-driven language is Visual Basic. Visual Basic allows programmers to make windows form applications which includes alot of graphics for the user to interact with which makes event driven programming very suitable for producing graphical applications.

Another example of an event-driven language is Python. Python is a language which is very simple to use when programming using the event-driven paradigm. There is a large amount of libraries to use when coding in python which makes it general purpose which can be used to code a variety of applications.

Pre-defined Functions

A pre-defined function is a function that is already there to use when coding in a language.
An example of a pre-defined function is StartsWith() which lets you find the character which is first in a particular string. 
Example
String sLocation;
sLocation = “Middlesbrough”;
if (sLocation.StartsWith(“M”) ) {   System.out.println(“You live in a very nice place”);      }
The code above shows the application creating a string called sLocation, setting sLocation as a place, then there is an if statement depending on if the string starts with the letter M.
Another example of a pre-defined function is println() which lets you display the line of text on the screen
Example
System.out.println(“ Hello there, this is a printed line”);


The code above shows the application printing the line of text . The text that is printed is the one placed in the speech marks.

Programming Libraries

A programming library is a library that contains files and functions which can be used in the project you are developing.
An example of a programming library is Swing. The code to import the Swing library into java is:
Import javax.swing.*;

Once you have imported swing, you can use functions like JOptionPane which can load up question messages where users can input text.

Modularity

Modularity in programming is where you split the program into key sectors or different parts. The code for each part does not rely on the other parts code. If you write all your program code in one part then it will not be efficient as some code may have to change which will affect other code. However if you modulated your code so that everything is set into different parts then your code will be more effective.

Global Variables

A global variable is a variable that can be used in all parts of your program. 

"Public Class GlobalVariables                               
                                              
    Public Shared UserName As String = "Tim Johnson"
    Public Shared UserAge As Integer = 39
End Class"

  http://stackoverflow.com/questions/14423568/how-to-have-a-global-dictionary-in-vb-net-wpf-application-to-save-data-from-diff - code reference 



This is an example of 2 global variables declared in visual basic. A global variable is declared in a public class so all forms can use the variables. The first one is declared as a string and is equal to “Tim Johnson”. The second declared variable is an integer which is equal to 39.

Local Variables

A local variable is a variable created which can only be used and defined in the part of the program where you have created it. 

" int iNumber = 10;
   String sNumberinwords = "Ten"
   char cCharacter = 'a'
"
This is an example of creating 3 local variables, an integer, a string and a character. As these are not in a global module, these can only be used in this one section of your application.

Service Orientated 

Service orientated is part of event driven programming. This is where you require a service to happen when you create an event. For example, when you plug in a keyboard or mouse to a USB slot, the operating system will install the drivers needed for the external devices to work. This service is ran in the background.

Time Driven

Time Driven programming is creating programs with timers on them. The programmer would set the amount of time you have to wait for the application to do something. The programmer would have to set the event that would happen after a period of time. For example, dimming the screen is a time driven program as after a certain amount of time, the screen will dim, if set to.

Events

Events in programming are actions that happen. This could be an action caused by a condition that has been met or not met, like an if statement. In event-driven programming though events usually execute due to changes in the mouse position or which keys have been pressed on a keyboard. Once you type something on a keyboard, an event will happen on the computer.

Event Handlers

Events Handlers are the parts of a program that checks to see if an event has happened and if it has then the event handler executes the piece of code which corresponds to the action of the event.

Trigger Functions

For event handlers to manage the actions and consequences of an event, a trigger function needs to occur to describe to the event handler what kind of event has happened. A trigger function occurs when the event has finished.

Parameter Passing

Parameters are the information which variables hold. This could be a Boolean, string or an integer. Parameter passing is when different classes and function swap the parameters over so that they can all use them.

Procedures

Procedures in programming are routines which hold a series of steps and instructions. A procedure can be called to execute in your program. Procedures are the physical implementation of modularity. A procedure will begin and end with the series of instructions inside of them. For example,
Reference : http://pascal-programming.info/lesson7.php
Procedure DrawLine; 
{This procedure helps me to 
 avoid the repetition of steps [1]..[3]}
Var Counter : Integer;

Begin
 textcolor(green);
 For Counter := 1 to 10 do
  Begin {Step [1]}
   write(chr(196)); {Step [2]}
  End; {Step [3]}
End;
Begin
 GotoXy(10,5);
 DrawLine;
 GotoXy(10,6);
 DrawLine;
 GotoXy(10,7);
 DrawLine;
 GotoXy(10,10);
 DrawLine;
 Readkey;
End.

The example above is a program that can draw a line. The procedure is how to draw a line. The begin and end are the actual actions that are going to be executed. The first begin is a loop and another begin is nested in the first one. Then the procedure ends. Then the new begin and end run.




2 comments:

  1. Your Affiliate Money Printing Machine is ready -

    Plus, earning money online using it is as simple as 1-2-3!

    This is how it works...

    STEP 1. Tell the system what affiliate products the system will promote
    STEP 2. Add some PUSH button traffic (it ONLY takes 2 minutes)
    STEP 3. Watch the system grow your list and sell your affiliate products all for you!

    Do you want to start making profits??

    Click here to launch the system

    ReplyDelete
  2. Programming: Key Features Of Event Driven Programs. >>>>> Download Now

    >>>>> Download Full

    Programming: Key Features Of Event Driven Programs. >>>>> Download LINK

    >>>>> Download Now

    Programming: Key Features Of Event Driven Programs. >>>>> Download Full

    >>>>> Download LINK z3

    ReplyDelete