Thursday, 6 November 2014

Key Features of Event Driven Programs


Key Features of Event Driven Programs.


  1. Service orientated.
  2. Time driven.
  3. Event handlers.
  4. Trigger functions.
  5. Events (e.g. mouse, keyboard, user interface.
  6. Predefined functions.
  7. Local variables.
  8. Global variables.
  9. Parameter passing.
  10. Modularity.
  11. Procedures.
  12. Programming libraries.
  13. Event driven programming paradigm for simplicity of programming and ease of development.
  14. Include two example programming languages as examples.


A: Service orientated programs are programs which appear in the background of an interface, However they have the ability of being stopped and started by a user. These programs use memory while running it the background therefore users may want to stop them. Examples of these program are things like Bluetooth. 

B:  Time driven programming is known as a programming paradigm, where the control flow of the computer program is driven by a clock.  This method is often used in real time computing. In event driven programming the time driven feature uses a specific code on a timely basis such as once an hour or once a month therefore this means it is pre-set to do tasks on time. An e.g. of this can be your operating system which will check for updates using time such as an update once a month. 

C: An event handler is a subset of a computer program that executes a specific event when a trigger is activated. Subset means “Being part of a larger group of related things” An example of this is if I clicked on the start button on my computer codes which relate to that very button will be activated.

D: The majority of event driven programming languages use trigger functions to choose which event handler needs be responsible for which event has occurred.  Every object has its own trigger function. In other words in event driven programming trigger functions are mechanism that decide what code to run at a specific event which can occur. For e.g. when you click an application and it sends a signal to open it.

E: There are many types of events firstly mouse events, moving a mouse in a certain direction will cause the cursor to react by responding to the movements. The left and right click buttons and the scroll all have triggers that are specific and event tied to them. Keyboard events, Pressing any key on the keyboard will have some sort of response for e.g. if you press the letter “A” then the display may display the letter “A” but whilst your playing a game pressing “A” may make your character jump. 

F:pre-defined functions, Predefined functions are methods which are already defined or in other word are built in the library of the program your using. For e.g. java have many pre-defined functions. I will give a few examples….
String sName;
SName = sName.toUpperCase ();
This is a pre-defined function within java as it is automatically tells the program to put the text into uppercase letters. This phase is already built into java therefore it is a pre-defined function. Alternatively another pre-defined function is….
SName = sName.toLowerCase ();
This is the exact opposite to the first phase as this time it is telling the program automatically to turn the letters into lower case letters.  Both examples are pre-defined functions as they are already built into the program. There are many predefined functions.

G:Local variables.  A local variable is a variable that is declared in the body of a method that you make. They you can use that variable only in the method you made. If you have other methods in the class they will not even be aware that the variable even exists. Here is an example of a program using a local variable…..
Public class HelloWorld
{
String sMyName;
      sMyName="Husnain";
      System.out.println(sMyName);
This is an example of a local variable. You don’t specify the static on declaration for a local variable, but if somehow you do the compiler will read the program and in return send you an error message and will refuse to compile your program. 

H:   Global variables;

 int g_nX; // global variable
int main()
{
int nY; // local variable nY
// global vars can be seen everywhere in program
// so we can change their values here
g_nX = 5;
} // nY is destroyed here

This is an example of a Global variable. Variables that are declared outside a block are known as Global Variables. Global variables have a program scope, in other words this means they can be accessed anywhere/everywhere within the program. The only way they can be destroyed is when the program ends as they are global. Unlike local variables Global variables can be accessed anywhere throughout the program. A global variable maybe used when you want to declare a variable that needs to be accessed by all parts of your program.   

I:Parameter passing; A parameter is a type of variable that you can pass into a function. Variables are the listed parts of each methods declaration. Each parameter must have a unique name and have a defined data type. For e.g. when you first open up java you get this code..
Public static void main (String[]args)
This this a type of function that takes one argument, an array of strings that’s called args. Furthermore there is a tye of way you write stuff to get input back.. System.out.println(“HelloWorld”). To sum up you have a function that takes one parameter. The value of the parameter is the string “HelloWorld”.

J)modularity;
Modularity is a general concept which applies to the development of software. It allows individual modules to be developed, in many cases this is done with a standardized interface to allow modules to work and communicate properly. Each module works independent to each other. Large software systems are really hard and complex to build this is where modularity comes in to break down a large system into separate physical entities that in a nutshell make it easier and more straightforward to understand.

K:Procedures are just small programs. They are sometimes known as sub-programs. The purpose of a procedure is to help a programmer avoid repetition. A procedure start off with a begin and end up with end;. The procedure can also have its own variables which cannot be used the main program. In a nutshell a procedure is a section of a program that performs a specific task or in other words an ordered set of tasks for performing some sort of action.

L:Programming Libraries; There are many Libraries in programming. They each contain some unique functions and subroutines for a specific program. For e.g. when I was programming to make graphical sub boxes to appear I had to write a specific code before inputting my codes.
  import,.javax.swing.*;
This code allowed me to have graphical boxes to pop up. When I typed this code it gave me access to a specific library. So I could use its functions and subroutines.

M: Event driven programming is a paradigm which is used to structure a program around multiple events. There are many events such as input in graphical user interfaces to networking requests. Nowadays most things use Event programming even non-graphical applications such as fire alarm. There are many advantages of Event driven programs...

  • It allows us to create and use more interactive programs, The majority of today's GUI are written with event driven programming.
  • It allows hardware to interact with software more easily 
  • Ease of development
  • Simplicity for GUI (Graphical user interfaces)
N: There are many Programming languages available, i will discuss two.
Advantages of Java....
Java is fast and easy to learn.
Java is object-orientated meaning you can create modular programs and re-usable codes.
Java is secure
And lastly java is platform independent……
Here are some advantages of c++
Great program for people who are interested in making games.
It is a good language to learn enabling you to limitless benefits
It is relatively clear and mature language
C++ is a great language however it may take more time to learn that a program like java as there is a lot more to learn
Java is a program used by many as it is easy and fun to learn. Java is now estimated to be running on 3 billion devices this shows how good and important the language is, C++ is used more for creating games and if you decide to become a programmer in the gaming section then you need to have brilliant C++ skills.



















Key features of procedural programming (P1)

Key features of procedural programming (P1)

Introduction: During this assignment i have been asked to discuss the key features of procedural programming and how and why it is used.


  1. Predefined functions.
  2. Local variables.
  3. Global variables.
  4. Parameter passing.
  5. Modularity.
  6. Procedures.
  7. Programming libraries.
  8. Procedural programming paradigm.
  9. Include two example programming languages as examples.
  10. Include samples of code including: if, else, else if, for, int, char, String, double and boolean explaining what parts do.

A: pre-defined functions, Predefined functions are methods which are already defined or in other word are built in the library of the program your using. For e.g. java have many pre-defined functions. I will give a few examples….
String sName;
SName = sName.toUpperCase ();
This is a pre-defined function within java as it is automatically tells the program to put the text into uppercase letters. This phase is already built into java therefore it is a pre-defined function. Alternatively another pre-defined function is….
SName = sName.toLowerCase ();
This is the exact opposite to the first phase as this time it is telling the program automatically to turn the letters into lower case letters.  Both examples are pre-defined functions as they are already built into the program. There are many predefined functions.

B; Local variables.  A local variable is a variable that is declared in the body of a method that you make. They you can use that variable only in the method you made. If you have other methods in the class they will not even be aware that the variable even exists. Here is an example of a program using a local variable…..
Public class HelloWorld
{
String sMyName;
      sMyName="Husnain";
      System.out.println(sMyName);
This is an example of a local variable. You don’t specify the static on declaration for a local variable, but if somehow you do the compiler will read the program and in return send you an error message and will refuse to compile your program.   

C; Global variables;

int g_nX; // global variable
int main()
{
int nY; // local variable nY
// global vars can be seen everywhere in program
// so we can change their values here
g_nX = 5;
} // nY is destroyed here

This is an example of a Global variable. Variables that are declared outside a block are known as Global Variables. Global variables have a program scope, in other words this means they can be accessed anywhere/everywhere within the program. The only way they can be destroyed is when the program ends as they are global. Unlike local variables Global variables can be accessed anywhere throughout the program. A global variable maybe used when you want to declare a variable that needs to be accessed by all parts of your program.        

D; Parameter passing; A parameter is a type of variable that you can pass into a function. Variables are the listed parts of each methods declaration. Each parameter must have a unique name and have a defined data type. For e.g. when you first open up java you get this code..
Public static void main (String[]args)
This this a type of function that takes one argument, an array of strings that’s called args. Furthermore there is a tye of way you write stuff to get input back.. System.out.println(“HelloWorld”). To sum up you have a function that takes one parameter. The value of the parameter is the string “HelloWorld”.

E: modularity;
Modularity is a general concept which applies to the development of software. It allows individual modules to be developed, in many cases this is done with a standardised interface to allow modules to work and communicate properly. Each module works independent to each other. Large software systems are really hard and complex to build this is where modularity comes in to break down a large system into separate physical entities that in a nutshell make it easier and more straightforward to understand.

F: Procedure; Procedures are just small programs. They are sometimes known as sub-programs. The purpose of a procedure is to help a programmer avoid repition. A procedure start off with a begin and end up with end;. The procedure can also have its own variables which cannot be used the main program. In a nutshell a procedure is a section of a program that performs a specific task or in other words an ordered set of tasks for performing some sort of action.

G: Programming Libraries; There are many Libraries in programming. They each contain some unique functions and subroutines for a specific program. For e.g. when I was programming to make graphical sub boxes to appear I had to write a specific code before inputting my codes.
  import,.javax.swing.*;
This code allowed me to have graphical boxes to pop up. When I typed this code it gave me access to a specific library. So I could use its functions and subroutines.

H: Programming paradigms; there are three standard programming paradigms that can be used to implement algorithms. The three paradigms are….
Procedural programming – this is a high level programming paradigm. This has a basic rhythm/sequence of statements. This is straightforward and simple way of programming as it does not get complicated.
Object orientated programming- this is more of a problem modelling. And has a specific way of structuring a program. This method contains data and methods.
Flow programming- flow programming involves chaining a sequence of smaller processes together and allowing a flow of information through the sequence.
There are many programming languages however some vary in the way they are written. Two examples of good programming languages are Java and C++.Here are two examples of the languages.
Public class HelloWorld
{
String sMyName;
      sMyName="Husnain";
      System.out.println(sMyName);
This is a example of java, as you can see this is a small and straightforward program. There are many advantages of using a program like java for instance..

I)
Advantages of Java....
Java is fast and easy to learn.
Java is object-orientated meaning you can create modular programs and re-usable codes.
Java is secure
And lastly java is platform independent……
Here are some advantages of c++
Great program for people who are interested in making games.
It is a good language to learn enabling you to limitless benefits
It is relatively clear and mature language
C++ is a great language however it may take more time to learn that a program like java as there is a lot more to learn

J) There are many samples of codes, here I will explain a few.
Integer: Known as an int int the java program it is used to declare an whole number this is good for various things from age to birthyear.
Boolean: Boolean is used to declare a true or false statement, in other words Boolean is a data type used to hold true or false data this cannot be used with math calculations. 
Char: This is used to declare a single character it cannot hold more than a character, this is good to declare sex (M or F) and many other things.
Data types: 
byte: this can hold numbers in the range off -128 to +127
short: this can hold numbers ranging from -32,786 to + 32,767
long: this can hold number in the range of -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
IF) IF statements are used alot in java, this is a method of asking the program a question. for e.g. if you have a requested a user to use numbers instead of characters then you may use an IF to detect any characters and to tell users to use numbers, An example of an if statement....

        if(sAge.contains("A")){
                            sAge = JOptionPane.showInputDialog(null,"please input your name in numbers  " + sName,"Enter your Age please...",JOptionPane.WARNING_MESSAGE);
This is telling the program to see if the letter A is found then to send an error message to0 the user telling them to write in numbers not letters.
Else and Else if: Instead of using IF twice you can use IF then Else this make your program look better and more efficient. Else follows after a IF and is executed when a Boolean is expression is proven false.
Here is an example....
if(sAge.contains("A")){
                            sAge = JOptionPane.showInputDialog(null,"please input your name in numbers  " + sName,"Enter your Age please...",JOptionPane.WARNING_MESSAGE);

        }else if(sAge.contains("B")){
                sAge = JOptionPane.showInputDialog(null,"please input your name in numbers  " + sName,"Enter your Age please...",JOptionPane.WARNING_MESSAGE);
As you can see this is an Else statement this is just a shorter way for the program to read through and find an expression which proves the Boolean false. If the first condition does not work then the program will check the second one.

FOR: The for statement provides a good and compact way of repeating a range of values, this is often referred to as a for loop by programmers as it repeatedly loops until a certain condition is satisfied. 

for (initialization; termination;
increment) {
statement(s)
}
This is an example of a For or for loop.
WHILE LOOP: The while loop is used to control a structure and it allows you too repeat a task a number of times. The while loop keeps repeating until the condition is satisfied, here is an example... 
    
int x = 10;
        
        while( x < 20 ) {
         System.out.print("value of x : " + x );
         x++;
         System.out.print("\n");
      }
This is basically telling the program to keep looping until the value of x is near 20, this means it will only loop till the number 19.


















Suitability of Event Driven Languages

Suitability of Event Driven Languages

Even driven can refer to any type of event, it is not necessary that it always thought to be linked to the programming side. Every day objects use event driven, particularly those products or objects which need to handle responses or requests. There are many non-graphical applications which use event driven programs. An example it a air conditioner. A air conditioner uses event driven programs because it has sensors. When it is hot they you may turn on the conditioners an supply cold air likewise when it's too cold you will turn it off. You also have an option to set the temperature when you do this and want to confirm it you will press a button and an event will be triggered where the conditioner will take the input and will output the cold air through the heater inside. Another example is a fire alarm. An fire alarm will sound off when it detects smoke, When it detects smoke an event is triggered and in response an alarm is sounded, This is one of the more important products which use event driven programs. As you can see the answer to the question is that Event driven programs are most definitely suitable for non-graphical applications. Lastly my last example is the fuel tanks in a car, When you are running low on fuel and even is triggered and a light flashes on your dashboard indicating this, This makes life a lot more easier as you will know when to fill up your fuel and when your running low. In a nutshell Event driven programs are most suitable for non-graphical applications. However for non-graphical applications you could use procedural programming, but event driven is now used in everyday products and its the way forward.

Event Driven Operating Systems

Event Driven Operating Systems

Today many things run on an event driven operating system. By event driven operating systems i basically mean a system that triggers an event in reaction to your action. For e.g. when you click the start button on a normal windows OS it reacts by opening this is done because when you click on the start button a trigger is activated and in response it opens the start button as an event.
As you can see on the screenshot when i clicked on the start button a trigger was activated and in result the start button opened up. We all benefit from an event driven OS as it makes using systems easier. An example is windows. Windows was first developed in 1985 and it was one of the first event driven OS on computers, this was revolutionary as users did not have to enter text on CLI (Command line interfaces) but could now navigate through a system with a mouse and could open graphical files and folders and applications with a click of a button. If it was not for event driven based OS then it would be harder using text based interfaces as we would have to remember a lot of text and phases to remember however event driven OS have made our life's easier as we don't have to remember text we just have to navigate with a mouse and with a click of a button we can open up graphical applications. These event driven OS have also been introduced to mobile phones making them more advanced and easier to use, They have also made it easier for people with disabilities to use products such as computers, tablets and mobile phones. This had made us inclusive as a society. Event driven OS allow us to use more dynamic interfaces. Taking this all in account event driven operating systems have allowed us to make brilliant GUI and without them using systems with out event driven would have made life more difficult.

Wednesday, 5 November 2014

Suitability of Procedural Languages for Graphical Applications

Suitability of Procedural Languages for Graphical Applications.

Procedural programming is most definitely suitable for making graphical applications, this is because procedural programming allows you to keep re-reusing a block of code over and over again. It is also known as one of the best alternatives for making graphical based applications due to operating systems such as Linux. Also graphical applications have to be given certain and specific steps in order to work and because of this it is a perfect match with procedural programming as the whole concept of procedural programming languages are to set straight and simple or in other words specific steps for a program to work. However there are better methods for graphical applications out there. Procedural programming is suitable for making graphical based application however they are not the best. A better method to use is Event driven programming as they are made for the purpose of making graphical applications.
This is my Example of a graphical application, as you can see when you run this program a pop up box pops up and ask's for your name. There are many techniques to make a graphical application and procedural programming is one of them however it is not the best way , in my opinion event driven programming is the best way to create graphical based applications. 

Modular Elements Are Important !

Modular Elements Are Important !

Modularity is a general concept which applies to the development of software. It allows individual modules to be developed, in many cases this is done with a standardized interface to allow modules to work and communicate properly. Each module works independent to each other. Large software systems are really hard and complex to build this is where modularity comes in to break down a large system into separate physical entities that in a nutshell make it easier and more straightforward to understand.
In procedural programming modular elements are a programming style in which the program is split up into small parts or chunks, each one of these chunks contribute to the program and perform a task. Procedural programming gives a computer  specific steps however modular makes it easier for the computer to understand the instructions.
As you can see this is my example of modular code. The code has been separated into modular elements. Skin colour, Name, Son, Weight and sex are all now modular elements. The whole code has been put in modular elements because it makes it easy to understand and it makes it easier for the computer to understand. 










































To activate the modular codes you have to add Set before the element. For e.g. (setWeight) then  you can set the weight to what you want. As you can see the whole code has been set into sub codes which makes it easier to solve and if any problems occur then its easier to solve. Also the code has been set into order such as name, sex and weight which is really good and easy top understand.

Advantages of using modular elements:
  • Modules can be re-used over and over again.
  • This technique is used when working as a part of a team as each member will have a different module to work on. 
  • It is easier to test a small modular program than a whole program and easier to find mistakes.
  • Programs which are not written in modules are harder to understand.
  • You can work on each module independently, Working on small parts at a time makes making a program a much faster and efficient process.