Monday, 3 November 2014

Key features of event driven programs


Service orientated.
Service oriented driven programming only runs when it is needed or when a event occurs like for example when a file is make or a new device is installed, these services can be ran in parallel allowing multiple actions to be ran at once.

Time driven.
A time driven is a code that uses time called a "timer", this is the trigger to this event. For example the timer could be set for a server to back itself up at 6pm everyday. Or a example that everyone knows is Google docs which saves automatically, this is a time driven event

Event handlers.

A event handler is a function or a method containing program statements that are executed once a event is triggered. A event handler is a routine used to handle the event that was triggered for example in javascript:
<form action="#" method="post">
<input type="button" value="Click for a Message" onclick="window.alert('Hello!');"> 
</form>

Once the button is clicked the event handler creates a pop-up saying "Hello!"


Trigger functions.
Trigger functions are used to identify and define which event handler should be ran after the trigger has taken place.

Events (e.g. mouse, keyboard, user interface.

In computing, a event is a action that can be detected by the program like for example in java when someone clicks a button it closes the JFrame, another example is when you start your computer up, if you press F12 it opens up the boot menu, pressing F12 is the event.


Pre-defined functions.

Predefined function in java are are functions which are defined inside of the java library. These functions are things like "System.out.println("Hello world!")". This predefined function displays a message on your screen saying "Hello world!". This predefined function can also be used to display other predefined functions, for example:
"String sName=”Alex";
char cPosition=sName.charAt(0);
System.out.println(“The letter at position 0 is “ + cPosition);"
In this, the first letter of the string sName is identified and then displayed on the screen.

Local variables.

Local variables are variables that are declared within methods and they are only visible withing the declared method. Local variables are useful for storing data but they are only available within the class it is defined in. Examples of local variables in java:
char cInitial='A';
int iAge=16;
The char method can hold one letter like in this example is "A". Whilst the int method can contain integers between -214748367 and 214748367.

Global variables.

A global variable is a variable that is visible throughout the entire program (unless the variable is shadowed). The set of all of the global variables is known as the global environment or the global state. But global variables are only accessible once they have been declared. For example in C++ a global variable that can modify age:
int age;
int main(){
           age = 18;
           int newage = age + 5;
}

Parameter passing.

Parameter passing is the mechanism/method used to pass parameters to produce a function. The most common method used is to call/ pass the value of a parameter or to pass the location of the parameter. The less used method for parameter passing is to change the value of a parameter. For example using C# this example shows both of these methods.
class Program
{
    static void Main(string[] args)
    {
        int arg;

        // Passing by value. 
        // The value of arg in Main is not changed.
        arg = 4;
        squareVal(arg);
        Console.WriteLine(arg);
        // Output: 4 

        // Passing by reference. 
        // The value of arg in Main is changed.
        arg = 4;
        squareRef(ref arg);
        Console.WriteLine(arg);
        // Output: 16 
    }

    static void squareVal(int valParameter)
    {
        valParameter *= valParameter;
    }

    // Passing by reference 
    static void squareRef(ref int refParameter)
    {
        refParameter *= refParameter;
    } 
} 

Modularity.

Modularity is designing a program or a system where it is divided into sets of modules that are can be used to create a larger application allowing it to be used and created easier as you can use the modules in other programs other than the one intended. Creating modules also makes the code a lot easier to read and debug and test. Here is a example of how modularity works.


Procedures.

Procedures are a structured section of a program that . Procedures are also known as methods, routines, functions etc... During any time of the program being executed a procedure may be called for example a string may be called at any time. A procedure is like a set of basic instructions for the computer to follow.

Programming libraries.

Programming libraries allow different methods to be used like for example, the package in java to use graphical resources is written like this:
import javax.swing.*;
Using this package/ library allows you to use methods such as:
String sName= JOptionPane.showInputDialog(null,"What is your name?","Name",JOptionPane.QUESTION_MESSAGE);
This will display a box on your screen asking for your name and if nothing is input it is saved as "null" or the string will be saved as what was input.

Event driven programming paradigm for simplicity of programming and ease of development.

Event driven programming is extremely simple and easy to used as you encounter less errors due to advanced debugging, the code may be paused and played when ever needed. When creating events in things like visual basic studios when making something like a button the code for the button is automatically generated for you needing less knowledge of programming to actually create a event driven program.  Prototypes are simple and easy to build and you can add extra features when ever necessary this can aid in rapid development for applications.

No comments:

Post a Comment