Wednesday, 12 November 2014

Key Features of Event Driven Programs.

Key Features of Event Driven Programs


Service Orientated

Service orientated is a service that applications all have. Phones have this in a way which you set an alarm and the outcome is for your phone to wake you up this is the service that you want he application to do.  

Time Driven
time driven programming is a form that depends on the systems internal clock to execute operations at a time preset by the code related to the operation. an example of this would be the alarm application on your phone, you set the time and then when the internal clock reaches the time you set it will trigger the alarm on the phone.

Event Handlers

An event handler is a procedure in your code that determines what actions are performed when an event occurs, such as when the user clicks any button. When an event is raised, the event handler or handlers that receive the event are executed. Events can be assigned to multiple handlers, and the methods that handle specific events can be changed dynamically. You can also use the Windows Forms Designer to create event handlers.

Trigger Functions

They are functions that are run when a certain event happens. What's actually happening is the program waits for you to press a key or cause some other change in the devices, and then sends a signal to the process. This wakes it up, and runs the trigger function

Events (e.g. Mouse Keyboards clicks) 
An event occurs when the user interacts with a object. Usually this means a mouse movement or click. Keyboard actions are also events. An event is the outcome of an action. There are two important terms with respect to events. The event source and the event receiver. The object that raises the event is called event source and the object that responds to the event is called event receiver

Pre-defined Functions
A pre-defined Function is lots of pre existing code that is there for the end user to use. Most programming IDE's will have pre-defined functions so that it easier on the user and written in style of English so users can understand what is going on. an example of a pre-defined function in Java is .length() this will look at how many characters are in the string and tell you the number of letters:

String sGreeting;
sGreeting="Hello";
int length;
sGreeting.length();
System.out.println("Greeting " + sGreeting);

Local Variables
A local variable is something that is declared within the body of a method, you are not declaring this variable in the public class because that would be a Global Variable. When you create a local Variable other methods in that class are not even aware that its there. an example would be declaring it in the public static void main body:

public class HelloApp
{ public static void main(String[] args) { String sHelloMessage; helloMessage = "Hello World"; System.out.println(sHelloMessage); }}

Global Variables
A global variable must be available everywhere, it must also be able to be used by function at any time. It's like given a piece of information about you to the public and they can do what they wish with that information.

Parameter Passing
The basic understanding of parameter passing is is a variable or value that you pass in to a function. Each parameter must have a unique name and a defined data type.
In Java you put parameter under the main public class for example: 

String sName;

public void setName (String sNewName){
sName = sNewName; 
       
} 

Modularity
Modularity in programming is Breaking down the design of a program into individual components. these can be programmed and tested independently. It is a requirement for effective development and maintenance of large programs and projects.


Procedures
A procedure performs a specific task in the code. A function will return a value whereas a procedure will just execute the commands. this an example in C the source will be linked at the bottom

void display( int n ) {
printf( "The value is %d", n );  

Programming Libraries
A Programming library is pre-compiled code that is stored for later use in a program. Libraries are particularly useful for storing frequently used routines because you do not need to explicitly link them to every program that uses them.

Event Driven Paradigm
The event driven programming paradigm is when the flow of a program is determined by events such as user actions, Keyboard clicks, mouse and a whole other range of peripherals. Event driven programming is the most used paradigm for graphical interfaces, they are centered for using user input of their applications. 

2 examples of languages using Event driven programming

The first language and the one we have really focused on is Java this is great for doing graphically user interfaces as you will see in the example.


As you can see this graphics box was made in java. The user interacts with the OK and Cancel button, whilst also entering the name with keyboard strokes.

The next example is in Visual Basic, this is great tool if your just starting to learn the basics of coding and is handy as it has pre made functions and GUI's to play around with.




As you can see the graphics box was made in Visual basic. The user interacts by inputting 2 numbers in which then program will perform the method you choose by clicking the radio buttons. 


Event Driven Operating Systems - M1

Windows
Windows is great for showing graphical user interfaces, most of the world uses windows because of its ease to navigate around. The first graphic you will probably go to on windows first is the start button at the bottom left of the desktop, it is activated through a click event. When you click on the button, it comes up with a list of other functions that can be done.  The action was when you clicked on the button and the event that occurred because of it was the list of buttons opening up.















Linux
Another example would be when you input a USB stick and it comes up with the multiple options of what files to open and what software to open them with.  For example, if you have videos on your pen drive, it will ask if you want to open them up in software player Ubuntu recommends you.  The event in this instance is when you put the pen drive in and the consequence is the operating system deciding to use that particular software.

















Apple
The final thing that I am going to use to tell you that an operating system is a type of event driven application or program is the fact that when you click on the shut down, the operating system gets shut and stops the power supply getting through the power supply unit and getting to the other key components that are required to run the computer.  The event in this instance is the user clicking the Shut Down button and the reaction from the operating system is the computer going off.















Suitability of Event Driven Languages - D1

Event-driven programs are just those that respond to some kind of requests and sit idle at other times. These are often graphical applications where the requests are things like clicking buttons. But there are other examples of event-driven programs that are not graphical. For example a server application could be event driven in that it does nothing until a client makes a request. There are many things in household appliances that have a non-graphical interface but use event driven languages for example.

A washer will use event driven code, the user will press the button spin on the washer, it will process it and the washer will begin to do the carried out task. This is just the simplest form of event driven being used without a GUI. 

A web server Idly sits around doing nothing until a client makes request to view a page. The application detects that the client has connected to the server. An event handler then allows this user to download and view the page. This wouldn’t be considered an intelligent application. An event driven language such as Visual Basic would be suitable to handle the events happening in this program, as it could prioritise the events in case multiple requests were sent at the same time.

Another example of technology that uses non graphical applications would be cars. The example that I am going to use would be when the sensor in the fuel tank notices that the fuel is getting low, it switches a light on on the dashboard which shows the driver that the car needs fuel. I believe that this is suitable for event driven programming because it would make the drivers life a lot easier because if the light didn't work, the driver would either have to look down the fuel filler tube which is very difficult or completely take the fuel tank off which is even harder.


Monday, 10 November 2014

Key Features of Procedural Programs

Key Features of Procedural Programs

Pre-defined Functions
A pre-defined Function is lots of pre existing code that is there for the end user to use. Most programming IDE's will have pre-defined functions so that it easier on the user and written in style of English so users can understand what is going on. an example of a pre-defined function in Java is .length() this will look at how many characters are in the string and tell you the number of letters:

String sGreeting;
sGreeting="Hello";
int length;
sGreeting.length();
System.out.println("Greeting " + sGreeting);


Local Variables
A local variable is something that is declared within the body of a method, you are not declaring this variable in the public class because that would be a Global Variable. When you create a local Variable other methods in that class are not even aware that its there. an example would be declaring it in the public static void main body:

public class HelloApp
{ public static void main(String[] args) { String sHelloMessage; helloMessage = "Hello World"; System.out.println(sHelloMessage); }}


Global Variables
A global variable must be available everywhere, it must also be able to be used by function at any time. It's like given a piece of information about you to the public and they can do what they wish with that information.

Parameter Passing
The basic understanding of parameter passing is a variable or value that you can pass in to a function. Each parameter must have a unique name and a defined data type.
In Java you put parameter under the main public class for example: 
{ public static void main(String[] args)

this is a parameter because the variable or value is being passed into a function. 



Modularity
Modularity in programming is Breaking down the design of a program into individual components. these can be programmed and tested independently. It is a requirement for effective development and maintenance of large programs and projects.













Procedures
A procedure performs a specific task in the code. A function will return a value whereas a procedure will just execute the commands. this an example in C

void display( int n ) {
printf( "The value is %d", n );  

Programming Libraries
A Programming library is pre-compiled code that is stored for later use in a program. Libraries are particularly useful for storing frequently used routines because you do not need to explicitly link them to every program that uses them.

Procedural Programming paradigm
Procedural Programming is a list or set of code that tells the computer what to do step by step and how to perform from the first code to the second. Any giving procedure maybe called out at any time during a programs execution.

Example of two programming languages

Two examples are Java and Visual Basic 

Simple Java code and fucntions

int - this stores denary data in the variable for example you could have
   
int iNumber = 7;
    
the int is storing the phrase iNumber and that is = to 7

if/else - the if statement executes a certain part of the code if the value is true for example
    
int iTrue = 7;
int iFalse = 10;
    
if (iTrue < iFalse) {
    System.out.println("This is True");
    }else {
    System.out.println("this is false");

    }

this is saying if iTrue is less than iFalse then execute the first System.out.println but if iTrue is bigger it will execute the else statement.

char - the char variable stores an alphabetical letter for later use. For example

char cFirstInitial = 'J';

this will store the letter J until declared.

String - The string variable will hold a piece of text. For example.

 String sMyName = "My name is Jeff";  

this holds the value My name is Jeff to use in a println or anything.

double - the double variable will introduce the point system into number. For example.

    double numberone, numbertwo, Answer; 
    
    numberone = 10.5;
    numbertwo = 12.9;
    Answer = numberone + numbertwo ;
    

    System.out.println("The answer is " + Answer);

the double holds the numbers 10.5 and 12.9 then is added together to show the answer.

Boolean
A Boolean value is one with two choices: true or false, yes or no, 1 or 0. In Java, there is a variable type for Boolean values So instead of typing int or double or string, you just type boolean (with a lower case "b"). After the name of you variable, you can assign a value of either true or false. an Example would be

boolean bExample = false;

if (condition){
bExample = true
}
if (bExample = true){
Statements

Else if 
You can have multiple else if statements declared. This means that if you have an if that's not going to work it can carry out the else if statements as back up for ex 

if(Boolean_expression 1){
//Executes when the Boolean expression 1 is true
}else if(Boolean_expression 2){
//Executes when the Boolean expression 2 is true
}else if(Boolean_expression 3){
//Executes when the Boolean expression 3 is true
}else {
//Executes when the none of the above condition is true.
}

M1



Why are Modular Elements important?



A programming design style in which a program is split up into small chunks that each do one part of the task. Modules can be used many times as its easier to test a small module than the whole program at any giving time. In the instance of having teams, different modules can be giving out to different team members, this meaning the program can be written faster. The programs that do not use modules are likely to be very large and hard to understand. In procedural programming you write the code like a set of instructions a modular design will break down the procedures into simple steps and then turned into machine code easily. An example of modular elements in java: 


As you can see in the example code i have set some variables at the top then underneath made some modular elements. These will set a new name for the human being we are building.

As you can see in this code we are starting to build the human up from all the smaller modules we created. Then you can easily show the characteristics in a println.












D1


Suitability of Procedural Languages for Graphical Applications.



Procedural Programming is not mostly suitable for graphical applications because while its still a step based programming language it has some advantages for example. You can show the results in a graphical box rather than just a System.out.println and mostly others like that. The example of showing procedural programming with graphical interface.


This shows the phrase "Hello user" + what you are due in dialog box rather than just printing in the event log.

Procedural programming is not the most effective for Graphical Applications. You want to be looking into Event driven code this is built for GUI's and is most suitable. Event Driven Programming uses user commands of peripherals and takes in the information effectively and displays the results back to the user, Procedural is just a step based programming language you can not input stuff into Procedural.