Friday, 21 November 2014

PROGRAMMING

Key Features of Event Driven Programs


Service oriented: Service orientated is a programming paradigm that's specifically used to write programs that are made for services. If something is requested, the action will be carried out, if a user wanted to minimize an application that they're currently using, they'd click the icon in top right of the page to minimize it into the task bar, this is service orientated.


Time driven: Time driven programmes like antivirus scans, task schedulers and operating systems are pretty important features when it comes to maintaining and running your PC. These events follow real time settings and variables in their programming generally are generally used to plan out maintenance and update tasks that occur on future dates and at future times. Because of the time settings they can be planned to take place at regular intervals that don't have to be independently monitored by the user.


Event handlers:


Event handlers within programming are sections of code that are made to denote the actions of event triggers within the structure of the code, for example, the effect it will have on the programme if you right or left click. The image above shows an example of sub procedure created in visual basic that uses the trigger of closebutton_click which means that a button within the programme will close when the user triggers it by clicking.

Trigger functions: Trigger functions are used to be able to designate a specific coded event with an action, for example, clicking a button to trigger the calculation on a calculator which works out the result based on the numbers you put in.


Events: Events can actually be sub categorized into five different categories which refers to different hardware and software uses of events. The five are, mouse events, keyboard events, HTML object events, form events and user interface events.

 
-Mouse events:
Mouse events refer to actions that are performed by the mouse which can be dependant on either mouse buttons or mouse motions and movement sensor.

-Keyboard events:

Keybaord events refer to actions that are performed with a keyboard, this is dependant on either individual key presses of any keys on the board or a combination, such as ctrl+alt+delete, causing the Windows menu to appear.

-HTML object events:

HTML events such as onclick, onmousemove and onkeydown is used in online applications using software like JavaScript and CSS. These triggers are not to be confused with hardware mouse and keyboard despite them being similar.

-User interface events:

User interface events are one of the key features of event driven programming because most applications that are made using event driven programming, like calculator apps use buttons as a graphical representation of the numbers.  

Predefined functions:
A predefined function can be placed after a variable and parameter.
A predefined function is a charAt which lets you find a specific position in a string e.g;

String sName;
sName=’Maison’;
char cPosition;
cPosition=sName.charAt(0);
System.out.println(“The letter at position 0 is”+cPosition)

Another predefined function is string.replace() which lets you replace a string


Local variables:
Local variables have the largest scope compared to the other variables. This variable is only accessible from the function or block where it is declared. Every local variable is immediately contained in a block ({...}) Local variable declaration statements can be mixed with other kinds of statements if they are in the same block. Local variables declaration have one single modifier and only one can be used. Local variables aren't actually given default initial values, they have to be initialized before they are used.


public class Cat{
  public void kittenAge(){
     int age = 0;
     age = age + 7;
     System.out.println("Kitten age is : " + age);
  }

public static void main(String args[]){
     Kitten = new Kittent();
     test.kittenAge();
  }
}


Global variables:
Global variables are variables that are visible throughout the program unless hidden, the set of all global variables is known as the global environment. To define Global Variable you need to make use of static keyword.


public class Software {
     public static int a;
     public static int b;


}

Parameter passing:
Parameter passing allows the variable values to be passed through the program to the procedure, look at the image of the code below, specifically, 'System.out.println( "Some Text Here" );', that's what will be displayed.
https://www.youtube.com/watch?v=YbBFZu8YJ-Y

Modularity:
Modularity is the definition of a modular programme. Modular programming is breaking up a computer program into separate sub-programs. A module is a separate software component. It's often used in a wide range of applications and functions with other components of the system.

Procedures:
Procedures are small programs that are known as sub-programs, procedures can actually be used to avoid repetition when you're creating your program. Procedures are a set of tasks, tasks, that can be carried out in an order, they can also be used to carry out certain actions you want them to.

Programming libraries:
A programming library or libraries(plural) is a pre-compiled routine like code, class, procedure and script which is able to be specified and used by a programmer when developing an application programme.

Event driven programming for simplicity of programming and ease of development:
Event driven programming can be a lot simpler and easier to use and program as it's more visual, for example, when you create things like buttons you can simply just select it and place it onto a form and then add the code to the button. Pre-written code can also be used in event driven programming along with the ability to select commands from drop down lists which show the commands that can be used, allowing for a faster development time, not to mention it becomes simpler and easier.

Examples of languages that use event driven programming:
Visual basic and C# use event driven programming.

Event Driven Operating Systems
There's many different ways that an operating system (OS) could be referred to as an event driven application. The first thing that's on an OS that could be considered event driven is the fact that the start button, typically on the bottom left of the screen, is activated through a click event. When you click the button it'll come up with other functions that can be done. The action was the button being clicked and the event that followed.

Another good example of how the operating system can be classed as event driven is the fact that there's drag and drop characteristics on the desktop. For example, the most common place to see the Recycle Bin on a computer desktop is normally in the top left corner. Another time drag and drop occurs on a computer desktop is when you want to place one thing inside another thing, for example; when you want to put a typed word document into a folder with similar documents.

Another good example of operating systems are event driven is the fact that when the user presses a key on the keyboard, it's registered as a KeyDown command which is linked with other data that's linked with the press, like which key the user's pressed. An example of this would be when you've created a new folder and you want to input a new name to it. The event here would have been when you were typing and the reaction being the fact the letters appeared on screen.

Wednesday, 19 November 2014

Application And Limits

Procedural programming paradigm
A procedural programming paradigm is a programming technique that works in a step by step method. In order for this method to work you have to create a sequence of instructions of steps, thus telling the computer what to do first and then second. Typical procedural programming languages are C++, C, FORTRAN, pascal, and BASIC. 

Application: It can help the user to solve the calculations for scientific and engineering usage.

There's several limits to this, the first one being it's pretty difficult to change once it's been modified due to the layout, making you have to search through the whole program to find the problem. Procedural is also difficult to relate with real world objects and becomes quite difficult to maintain when the code becomes larger. Procedural languages also don't have automatic memory management like some languages, making the programmer worry about the memory management of the program. There's also no security to the data, leaving it all exposed.



Object Oriented Programming
Object oriented programming is a a programming language model organized around objects rather than actions and around data rather than logic. Object is best described as its own class in programming and it has two key areas, state and behaviour. Oriented programming is also a type of programming, not only does it describe the database of a data structure but it also describes the types of operations. Most languages are actually developed using the OOP concept. C++ and Java are examples of OOP. 

Application: 
It's actually easier to modify the code. Object oriented programming encourages the programmer to place code in classes so it's less directly accessible by the computer system, instead, the data is accessed by calling specially written functions, these are called methods. The methods act as a special rule of sorts which are used to change the code.

Limitations:
Object oriented programs are bigger in file size due to the lines of code they use for standard applications, this means that they'll slower due to the bigger amount of memory usage. Object oriented programs also require a lot of work to create. Meaning a great deal of planning goes into an object oriented program well before a single piece of code is even written, initially, this early effort was felt by a big chunk of people as pointless and a waste of their time. Programs were a lot larger, causing coders to spend way more time actually writing the program.


Event Driven Programming
Event driven programming is a way to allow the programs to respond to several different inputs or events. This is a programming paradigm in which the flow of the program is determined by the events of movement. The signals can be from any source, it doesn't matter, and most common are timers, input devices and sensors.

Application:
Event driven programming is normally interactive programs, making it extremely important for user based programs due to modern GUI (graphical user interface) programs using event driven programming, for example desktop publications and audio editing software.

Limitations:
Event driven programs normally require a larger amount of processing power due to the need of continuously active event loops. Therefore, more processing power will be required for the computer. Event driven programming is more complex, making it harder for smaller programs. The flow of the program is usually less logical and obvious too.


Choosing a Programming Language

Support and configuration
Platform support is a fairly important factor that decides which programming language to choose. For example, application to be deployed on Microsoft platform can actually be programmed using Microsoft's programming suite like Visual Sutdio whereas Internet applications and mobile applications can be coded fairly easily with Java. PHP and HTML can also be used when it comes to internet applications as it depends on the utility of the application on the platform type.

Development time
For quick development of the project, high-level languages like Visual basic can actually be used to accelerate the pace of development. However, where time is not a constraint for the client, some other programming language in the same category of application like C/C++ can even be used.

Development cost
In order to suit the budget of the end-user or client, the selection of the language does actually make a difference to the budget. Languages where the license must be purchased separately will cost more compared to open-source languages. This is the reason that PHP applications are more economical over ASP.net applications.

Efficiency: The efficiency of an application depends upon various factors and the selection of programming languages is one of the major ones that influences performance. If we put it in the context of web application development languages, like Perl and PHP, Perl is supposed to be more efficient than PHP in terms of its speed and usefulness, but, PHP can be learnt easier and it's easier to implement.

Reliability: How much an application will last under stress condition is another major factor which decides the selection of a language for an application. In-built features of these specific languages make them more reliable and less prone to failure or crashes.

Benefits of Data Types
Having many different data types have several benefits and advantages. You can efficiently store data without wasting it and it allows you to write your application code without re-implementing standard data types. The various datatypes also allow the developer to describe how the data is to be stored inside of a program. It also allows the developer of the code to understand the maximum and the minimum values that could and might be stored there. An example of a data type is string, string is very useful for programmers because it can hold multiple characters without needing to use the data type char. Here's an example of some string:
char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.' };
String helloString = new String(helloArray);
System.out.println(helloString);

Char is also another data type that's extremely useful to programmers, you'd use char when you need to hold only a single character. When you use char you'll need to use quotation marks, here's an example of char:
char ch = 'a';

// Unicode for uppercase Greek omega character
char uniChar = '\u039A'; 

// an array of chars
char[] charArray ={ 'a', 'b', 'c', 'd', 'e' }; 

Floating point is another data type in which the number in it have decimals (1.2, 4.6). Floating point is similar to integer but as said before, it has decimals and integer doesn't. There's also no fixed numbers before and after the decimal point.
0.085:
bits:    31   30-23           22-0
binary:   0 01111011 01011100001010001111011
decimal:  0    123           3019899

Boolean is apart of a larger group of algebra that is used for creating a true or false statement. A boolean can be written in both algorithms and coding.
  • Syntax refresher:
  • return true; -- return true immediately
  • if (a > 20) { ... }
  • && -- and
  • || -- or (vertical bars)
  • ! -- not (exclamation mark
  • if (a <= 10 && b >= 20) {
      // run here if above is true
    }