Tuesday, 2 December 2014

Benefits of data types

When using a programming language, there are lots of different data types you can use and each data type has its own advantages but also its disadvantages. Here is a list of each data type:

  • Boolean- This data type can only be true or false answer. 
  • Char- This data type can contain one character. 
  • String- This data type has the capability of storing multiple characters and punctuation. 
  • integer- There are a few different types of data types for numbers, there is float, double and int. These data types allow you to do things like equations, for example things like simple addition or even more complex things like areas of certain shapes etc...
  • Object- Any data type may be stored as a object, this is helpful if you are thinking of later on changing them into a different data type using certain codes like: "Integer.parseInt".

Having lots of these different data types allows multiple functions while using less memory in order to run them. Knowing the various data types also allows for a easier debugging process as you will know the exact amount you can place in each data type, for example you wouldn't try and place more than one character inside of a char, this will cause an error, stopping the program. Therefore you would know that you had to use a string instead.

Event driven operating systems

How operating systems may be considered as an even driven application.

First of all, when a computer has peripherals attached to it, the operating system tracks what each of these devices does. For example when you move your mouse this is considered an event, then if you click on something like a file the operating system would respond to that by opening the file or even running a program which can open the file like windows explorer.
Doing simple things that we don't even realise are events happen all the time, like when the start menu is opened, this is caused when you either click on the windows button or press the windows key on your keyboard.

















Another reason why I think a operating system con be considered an event driven application is because of things like being able to things like the drag and drop feature which allows you to move files into different locations without needing to do anything like you would have to do on a command-line interface. The operating system does all of these things for you by controlling events.











Another way in which a operating system can be described as a event driven application is because when things like USB pens are plugged into a computer, it opens up a window asking what to do with the device. Also when you plug in peripherals such as keyboards, mice, webcams etc... The operating system realises if the device needs to have drivers installed to use the device and does this without the user needing to do anything.
















My final point is that when you are on the start menu, the operating system is able to handle a lot of events like for example, if you click on the power off button then the computer activates and event where it goes through a process of shutting down all of the processes and then turns of the computer in a way to make sure no damaged is caused to the system/ the system's data unlike when you hold the power button and do a force shut down.

Thursday, 6 November 2014

Choosing a programming language

When choosing a programming language, there can be many factors that can influence your choice. For example, if a programming language uses lots of symbols and has a illogical structure and you are new to programming, more then likely you're not going to use that language.

Ease of learning

Ideally if the language is a very easy to learn, for a beginner they are more likely to learn this language other than a language that is really complex and has a . For example visual basics is easier to learn than something more complex like Java or C++. But after programming for a while, this becomes less of a factor due to learning other languages and understanding the complex structures.

Ease of understanding

Understanding a programming language can be either simple or complex. For example a procedural programming language which reads the code in steps/stages allowing you to write a logical code which will be a lot simpler to understand than a programming language that uses event driven programming language which uses lots of loops to check for active events.

Speed of development

Speed of development can be very important in choosing a programming language especially if you have a deadline. Different languages have different ways of writing the same or similar code, each one of these can vary in length, like if two different languages try making a graphical box with a input forum.

Fit for purpose

This is undoubtedly the main reason for choosing a programming language. Like, if you're wanting to make a event driven program, there is no reason to choose a program which is procedural based as this will be incompatible for what you are trying to make. If you are wanting to make a program which uses several different features like procedural, event driven and object orientated, you would use a programming language like java or C++ etc...

Compatibility

This is another important factor as depending on the platform you are wanting to program for decides what the list of languages you are able to use, if you are trying to design a program for a android device, you're not going to use a programming language like batch as it will be incompatible therefore making the code useless to the system it was designed for.

Wednesday, 5 November 2014

PARADIGMS- Application and limits.


Procedural programming paradigm.

Procedural programming is programming that works in steps, it can be used to create a series of instructions. Its practical application is being able to solve calculations for things like scientific or engineering usage.
In this code snippet, it shows the calculation of one person's gamer score over a months period.


Event driven programming paradigm.

Event driven programs allow you to make programs more interactive, this is very important as all modern programs which us a GUI are event driven. It allows sensors and other hardware to easily interact with the software. The disadvantages/ limits to event driven programming are things like when trying to make a simple program, the coding may become too complex and illogical. Also, these programs take up lots of processing power due to their constant active loops.













Object orientated programming paradigm

Object orientated programming is a programming language which is based/ organised around objects instead of actions and data. The applications of object orientated programming are:
  • It is easier to change and modify codes.
  • It encourages the programmer to place the code inside of the class so its not as directly accessible from the computer's system, instead the system needs to call the data to be able to use it.
The limitations of object orientated programming are:
  • Files are larger due to many lines of codes therefore making the program harder to run/ run slower.
 

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.

Thursday, 23 October 2014

Modular Elements Are Important

What is modular?
Modular is where you divide a system/ program into smaller sections called modules, these can be created individually then implemented into different systems/ programs.


Why are modular elements are important?



Modular elements are important for procedural programming because it is a design style where a program is split up into smaller sections allowing each module can be designed by a individual, therefore making the design of the system easier. Using modular elements allow the program to be a lot simpler and not complex therefore you can use each module in different programs and they are easy to debug due to them only being small in comparison to a long complex program. For example the code to the left is split into a modular, this is to make the program a lot easier to understand. When a program is split into different modules, maintaining the program is easier than when it is a long complex program. 

Wednesday, 22 October 2014

Key features of procedural programs

Predefined 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;
boolean bAlive= true
string sName="Alex"
The char method can hold one letter like in this example is "A". Whilst the int method can contain integers between -214748367 and 214748367. Boolean is a true and false question like for example asking if someone is alive. A string is a variable which can hold a mixture of numbers, letters and symbols, these are very useful for storing all types of data.

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. Each programming library has its own preset routines/methods but if you use a programming language like java then you have to import the library each time. 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.

Procedural programming paradigm

Procedural programming can be defined as a subtype of imperative programming as a programming paradigm based on the concept of calling procedures, this means that statements are structured into procedures (also known as subroutines or functions). A procedural program is usually made of several modules.