Tuesday 18 November 2014

Suitability of Event Driven Languages. D1

In this post I will describe how suitable is Event Driven Language for non graphical applications.  Before I do that, I will first of all I would like to tell me readers what Event Driven Language really is. Event driven programming relies on the user to give inputs to a program and then the program executes instructions accordingly. Outputs can be in the form of sound, graphical message or a physical process in case of  a machine. The process is based on the concept of "if statements" ,  "else if statements" and "else statements" For example, if the user inputs this, then  then give the user that else if the user inputs then give the user that else give the user this.

Now I will explain about the suitability of event driven languages on non graphical applications in comparison to graphical applications. When we look at graphical applications, the first thing that comes to mind should be a software. More specificly , an operating system. In my M1, I explain how an Operating System is heavily based on user interaction and thus giving the conclusion that Operating Systems are event driven. Now as you know, Operating Systems are used widely and vastly throughout the world. However this does not mean the graphical applications are taking over non graphical applications.

Event Driven Languages are used in non graphical applications as well. When I say "non graphical applications" I mean Microwaves,Washing Machines and even our day to day peripheral devices such as a mouse or a keyboard. The absence of machines such as a microwave and a washing machine could cause great disturbance in our day to day life. Without Keyboards and a mouse we could not even perform the basic functions needed to operate an operating system so event driven is essential for non graphical applications.

The use of graphical applications seems more appealing to users than non graphical applications. The greatest example infront of us is DOS. DOS did not have a graphical user interface. It used to have a command lines. After a while, Microsoft developed a Graphical User Interfaced Operating System by the name of Windows. Windows was much preferred over DOS. Another example infront of us today is the use of a keyboard. We can judge that over a vast period of time, keyboards will remain non graphical and would continue to be so as they do not require a graphical unit. One last example that I would give you is the TV remote. This is also a non graphical application.

It does not seem to us that Event driven will be used completely by graphical applications in the future. The use of non graphical applications via Event Driven have always remained in some areas and look as if they will continue to remain.

Monday 17 November 2014

Event Driven Operating Systems M1

In my post I will be explaining how operating systems can be viewed as Event Driven applications. First of all I'd like to explain what Event Driven Applications really are. These applications rely on user to give them a specific input. When I say input, it could be a click, a press of a button, or even a touch on the screen (touchscreen devices). I will talk about "Windows 7" as an operating system because it is very famous and common among PC users. It is used world wide.

Start Button, Shut Down and Programs:

The start button on the modern keyboards or on the bottom left corner, when clicked, triggers an event that allows you to shutdown your keyboard with another click. You can even restart your computer or log off. Another thing it allows you to access is the Control Panel. By clicking the Start Button, you can also access various other programs by simply clicking on "All programs". This will load up a list of programs that are installed on you computer.

Keyboard text input:

Another reason why I think that Operating Systems are event driven is that it uses the keyboard. The keyboards contains buttons that are used to input specific numbers,symbols,spaces or even alphabets. There are some commands as well such as backspace or space or enter. While working with a word document, whenever we type (like I am right now) will come up on the word processor like so. This means that the user pressed a button which led up to the operating system to display that specific character on the screen for the user to see. This has to do with typing up documents.
Now, I will talk about using the keyboard for inbuilt functions. If we press Ctrl + Alt + Del it will load up the task manager. This is a useful utility. The computer depends on the user to enter these three keys simultaneously and detects the pattern. Also, I will talk about keyboard shortcuts. If we are using Google Chrome, a very common web browser, and if we want to check our history, we can press Ctrl + H to view it. This also depends on the user to trigger an event.

Keyboard commands:

On keyboards, there are specific commands that users can apply to their computer. Buttons like "F5" refreshes the desktop/page. Ctrl+Alt+Del loads up the task manager which allows you to review the functioning of your computer. The "pgup" allows you to scroll the page you are loading towards the upper section and to scroll down there is a button called "pgdn" . Often on keyboards there are three lights, these indicate "Caps Lock"  and  "Num Lock" If we press these buttons, we see the light blink on the keyboard that indicates that Num Lock is activated or Caps Lock is activated. If the light is off then it means they are deactivated. This again tells us about the event and trigger functions,
On laptop keyboards especially, there are buttons for screen brightness that allows you to control how bright or dim the screen will look. Also there are buttons to maintain the volume of the sound output. More commonly, there is a button to shut down the computer.

Mouse Click/Touch-pad touch:

One of the most common example (After keyboard buttons) that demonstrates that Operating Systems are event driven is the actual interaction between the computer and user via the mouse/touch-pad. I will be talking about the mouse, the principle of the touch pad remains the same.
The mouse is used actively throughout the user session. It is useful when you want to open files on your desktop. You have to "double click" the left mouse and your file opens up. To move the file into other folders you have to make use of the mouse by holding the left click button and dragging it onto the folder you want your file to be placed in. If you want to refresh your browser, you have to press the right click and select the option for refresh. In case of using the web, the mouse is useful when we want to highlight texts. Another reason why I feel that Operating Systems are event driven is because when we move a mouse to a hyper link, it often changes colour. It detects the interaction of the user and when the mouse is "hovered" there, it automatically changes colour. If we have previously visited that hyperlink then it's colour would already have been changed even before you hover your mouse onto it.

User Profiles:

The Operating System allows you to have multiple user profiles. When clicked on the profile, it often asks for the password. If the user manages to get the correct password then their own personal and unique desktop is loaded up where there private files are kept. The desktop can be changed in the sense that the font below icons can be changed, the background can be changed, the colour of the task bar can be changed and the user can even change the resolution. This relies on the user to trigger an event, which can be done by right click and then properties.


These are the reasons why I believe that an Operating System is purely Event Driven.

Friday 7 November 2014

Key Features of Event Driven Programs P1

A. Service Orientated: This feature provides a service to the user. The advantage of this feature is that it does not take much of the processing power. Thus preventing lag or slow processing. An example of service orientated could be that you put an alarm for 8:00 PM. The service would be the alarm going off at 8:00 PM.

B.Time driven: This feature runs a unique code in it's own unique time. It could even be in intervals. Like the previous example I mentioned about the alarm clock, it could be applied to this as well. Meaning that if we put an alarm for 8:00 PM, it could be an example of the Time Driven feature.

C.Event handlers: This feature is a form of interaction. For example if a user presses this button then this happens. Meaning that a unique action is carried out right after a unique event is triggered. An Example can be that if a user presses the "F5" button on the keyboard then it refreshes their desktop. Another example can be that while using Microsoft word, if we press "Ctrl" and then "S" then it would save our word document.

D.Trigger functions: These functions decide that which code is appropriate when a unique event is occurred. They also select the event handlers for unique events. An example could be if we use our fingers on a touch screen. If we slide our finger to unlock then it is an example of a trigger function.

E. Events: There are many types of events. Events triggered with the mouse can be the scrolling,clicking, and even moving. The right click would trigger events differently compared the the left click. Events triggered with the keyboard can be the buttons. For example the navigation keys. User Interface can also trigger events. Things like Web Browsers are an example.

F. Pre Defined functions:
  
   Pre defined functions are unique inbuilt functions that do specific jobs to meet the end user need.        They are inbuilt hence their name is "Pre defined".

       An example can be:

cPosition= sLastName.charAt(0);  //charAt(0) is a pre defined function. It links variable sLastName with cPosition to detect a position at position "0"

 System.out.println( cPosition); //System.put.println is a pre defined function. It prints out a message that shows position at 0 (of sLastName)

G. Local variables:

Local variables are variables that are defined to a specific function or subroutine or class/module and can't be accessed by other functions/sub routine.If some programmers are working on a big programme then it is useful to use local variables as they can be accessed easily for specific jobs,

     public class HelloWorld{

     public static void main(String []args){


   String sLastName= "Abbas";  // sLastName is a local variable inside the class HelloWorld

}
 }

H. Global Variable
Global Variables exist outside all functions and are accessible throughout the programme by any function/class. They are used for storage hence they can be accessed later on in the programme. However programmers do not like to work with Global Variables as they often cause bugs can consume memory behind the processes even though they are not being used in particular. Also, if the function is repeatedly, the global variable does not get renewed. Java does not have global variables.In VB6 it goes like this

Dim Num as Integer

Private Function PrintNum()

End sub

I. Parameter Passing:
Parameters are needed for a pre defined function in order for it to work. I will show you an example I have used previously for "Pre Defined functions".
 If we take a look at "cPosition= sLastName.charAt(0);". The integer in the brackets of .charAt(0) is the parameter that is being passed. It finds the character at position 0 . This is known as Parameter Passing.



J. Modularity

Modularity is the concept/idea or process of dividing the programme into different parts or sections. After it is divided, it can be tested and debugged section by section. This helps programmers to maintain the programme more efficiently. For example, if there is a bug, they would not go through all the code, they can test each function separately,for ease. It saves time and energy. Each function/module is independent from the other module/function. In the programme the user inputs are specific in the form or medium of "arguments" and the "result" or "output" is in the form of "return values"

K. Procedures: 
Procedures are a compilation or a body of statements that interact with each other to perform a specific function/operation or task for the user. The following is an example of a function/procedure from VB6. It takes two numbers and adds them together.
"Function Add(ByVal Number1 As Integer, ByVal Number2 As Integer) As Integer Add = Number1 + Number2 End Function"

L. Programming Libraries:
Pre compiled modules are saved,in object form, in a place called "library". The advantage of programming libraries is that once the routine is saved, it can be used again by a "linker" so we do not need to insert them to every software that requires the module. It could be accessed easily by the linker. It is usually stored in a .DLL file. Basically, without Libraries, we can not run a programme as the procedures are stored in it.

M. Event Driven Programming Paradigm:

Event Driven Paradigm has to do with interaction. By interaction I mean user inputs. For example, when the user presses this button then this happens, if user presses that button then that happens. This can have to do with our washing machine, microwave etc

J. Two event driven languages:

1. Java    2.  C++

Java is class based and object orientated.  The syntax comes from C and C++.

C++ is an intermediate level language. It also contains Object Orientation. It was used to Modify "C" language 

Monday 3 November 2014

Suitability of Procedural Languages for Graphical Applications. D1

Procedural programming is based on programs that runs in the series of "steps". In the program, different procedures are inputted by the programmer, thus building a program. In procedural programming, the case is that the solution is already inputted by the programmer and the user just has to usually run the program. The program loads up the basic functions and runs them, giving solutions. Procedural Languages are suitable for Graphical Applications, however they are suitable to a limited extent. One use of Procedural Languages in graphical applications is the Windows Calculator that looks like this(Attached below). Event Driven Languages are more suitable to Graphical Applications  as compared to Procedural                                                                                                                                      
Windows Calculator

Saturday 1 November 2014

Modular elements are important. M1

Whenever a programmer is working with a large program, he/she tends to divide the program into "chunks". Now this process of dividing a large, complex program into chunks is known as "Modularity". In C# programming language there are Modules. Modules,Functions,Procedures mean the same thing but are different in names because of the context and terminology.  In procedural programming, a complex program is divided into Procedures.

The advantage of this is that modules can be used more than once in a program, or it can't be used at all. We can single out one module from the whole complex program and test that individual module desperately to make sure it does it's desired function. One more great advantage of  modular elements is that if, for example, a company want's to make a program for some task,and the programming team has been told that this program is very complex, the team can divide the s.work load amongst themselves so that there is less time consumption and more productivity. So for example, if the team is of 6 people and there are at least 12 functions to be used in the whole program, the team would divide the programme by giving 2 modules to each person to build.
By using modular elements in a program, it reduces the risk of 2 elements being involved unnecessarily during the run time of the program. Without modular elements, we would have a hard time trying to find bugs and glitches in our complex program

A real life example can be

Humanbeing someguy= newHumanBeing();

someguy.setname ("Abbas");



Monday 20 October 2014

Key Features of Procedural Programs. P1

TASK 1 Unit 16


A.Pre Defined functions:
  
   Pre defined functions are unique inbuilt functions that do specific jobs to meet the end user need.        They are inbuilt hence their name is "Pre defined".

       An example can be:

cPosition= sLastName.charAt(0);  //charAt(0) is a pre defined function. It links variable sLastName with cPosition to detect a position at position "0"

 System.out.println( cPosition); //System.put.println is a pre defined function. It prints out a message that shows position at 0 (of sLastName)


B.Local variables:

Local variables are variables that are defined to a specific function or subroutine or class/module and can't be accessed by other functions/sub routine.If some programmers are working on a big program then it is useful to use local variables as they can be accessed easily for specific jobs,

     public class HelloWorld{

     public static void main(String []args){


   String sLastName= "Abbas";  // sLastName is a local variable inside the class HelloWorld

}
 }



C. Global Variables:


Global Variables exist outside all functions and are accessible throughout the program by any function/class. They are used for storage hence they can be accessed later on in the program. However programmers do not like to work with Global Variables as they often cause bugs can consume memory behind the processes even though they are not being used in particular. Also, if the function is repeatedly, the global variable does not get renewed. Java does not have global variables.
In VB6 it goes like this

Dim Num as Integer

Private Function PrintNum()

End sub



D. Parameter Passing:
Parameters are needed for a pre defined function in order for it to work. I will show you an example I have used previously for "Pre Defined functions".
 If we take a look at "cPosition= sLastName.charAt(0);". The integer in the brackets of .charAt(0) is the parameter that is being passed. It finds the character at position 0 . This is known as Parameter Passing.

E. Modularity:

Modularity is the concept/idea or process of dividing the program into different parts or sections. After it is divided, it can be tested and debugged section by section. This helps programmers to maintain the program more efficiently. For example, if there is a bug, they would not go through all the code, they can test each function separately,for ease. It saves time and energy. Each function/module is independent from the other module/function. In the program the user inputs are specific in the form or medium of "arguments" and the "result" or "output" is in the form of "return values"

F. Procedures:
Procedures are a compilation or a body of statements that interact with each other to perform a specific function/operation or task for the user. The following is an example of a function/procedure from VB6. It takes two numbers and adds them together.  

"Function Add(ByVal Number1 As Integer, ByVal Number2 As Integer) As Integer Add = Number1 + Number2 End Function"
G. Programming Libraries: 
Pre compiled modules are saved,in object form, in a place called "library". The advantage of programming libraries is that once the routine is saved, it can be used again by a "linker" so we do not need to insert them to every software that requires the module. It could be accessed easily by the linker. It is usually stored in a .DLL file. Basically, without Libraries, we can not run a program as the procedures are stored in it.

H. Procedural programming paradigm:

Procedural programming is a form of structural programming where the programmer types something similar to an "algorithm" and the program does its work. The advantage of this is that the programmer or anyone who sees the code does not have much difficulty in understanding the code as it has some "English terminology" in it. Which means basic English language words. Procedural Programming paradigm involves procedures, which anyone can tell by the name of it. The basic concept is that it follows "steps" to give an output using procedures.

I. Two examples of Procedural programming paradigm languages
 Two common languages are:

   1) Basic              2) Pascal


J. I will start by explaining the if, else if, else statements

  if: The if statement is continued by the "{ " statement and ended with "}" (in java). As the name tells us, this command is given in specific circumstances where if the user gives a specific input then       ("") the program should give a unique output (And then ended with a "}" ). An else if statement can be used when there is a selected alternative in-putted by the user. The else if is again continued by the "{ "statement which outputs information accordingly and ended with "}".. An else statement is used where the user inputs something that is not recognized by the program. It is also followed by a "{" statement that outputs information accordingly and is ended by,once again "}".
An example for all 3 of these statement can be

public class HelloWorld{

     public static void main(String []args){
       if (2>1){
    System.out.println("2 is bigger than 1");
       }
       
else if(1==1){
    System.out.println("1 is equal to 1");
}
    
else {
    System.out.println ("Error");
}

                                          }
                      }
 

Now I will explain what "char" is,
The full form of "char" is character. It is a data type. In computing terminology, a character is a single letter,number, symbol or space. This data type can be used as demonstrated below

char cFirstInitial="A";

Now I will explain what "double" and "int" are.
This data type is a bit similar to integer. However it is used for decimal numbers such as "9.1"  "2.3" whereas integers can not be applied to decimals and are used for whole numbers such as "9"  "1"  "23". If we take a look at the range of double, it is 4.94065645841246544e-324d to 1.79769313486231570e+308d but for int it is -2,147,483,648 to 2,147,483,647.

A variable can be used as an integer and doubles as follows

int iYearOfBirth //for Integer

double iPriceOfCake //for double




I will now explain "for".


"for" is used where the program loops a specific code. The number of times it is "looped" has to be specific amount of times. I will demonstrate an example. If I wanted to increase the value of "iTotalScore" by 3, 5 times, then I would use:



int iTotalScore = 5;

int iAdd = 3;

for( int iLoops=0; iLoops<6; iLoops++) {

System.out.println ("Total score is " + iTotalScore);

iTotalScore+= iAdd;
}
 Which would look something like so,


I will now talk about String. String is made up of different characters. By characters, I can mean symbols,spaces or even numbers and letters. These all add up to make a String. A String is usually in speech marks, And example can be

String sSurName = "Abbas";


Lastly, I will talk about boolean. Boolean is identified by just two things. It is either "true" or "false". An example can be boolean bFirstNameMuhammad = "true";
My first name is Muhammad that means it is correct.