Saturday, 22 November 2014

Key Features of Procedural Programs


Pre-defined functions
Pre defined functions are set of subroutines that perform mathematical calculations when called upon and are either included in a program at compilation time or called when a program is executed.

Local variables
A local variable is a variable that is only accessible in a certain part of the program, such as a single function.

Global variables
Global variable are the opposite to local variables. These variables can be used throughout the whole program.

Parameter passing
Parameter Passing allows the value of the variables to be passed through the program to the procedure

Modularity
Modularity is the method of splitting your code into separate pieces, or modules, instead of it being all together. This is done for a few reasons, the first being that it makes the code much easier to read. It also makes the code easier to debug as the problem will be found much faster.

Procedures
A procedure is a set of commands that are executed in a certain order. This is often confused with Functions as they are really similar, the main difference being however is that functions return a value whereas Procedures do not.

Programming libraries
These are a collection of pre built source codes, sub routines, classes etc. That are stored in the program and can be used by the program or user at any time. An example of this is the Scanner Library in Java.


Friday, 21 November 2014

Suitability of Procedural Languages for Graphical Applications (D1)

Procedural languages are good for graphical applications as they allow the user to input the information without having to look at the code, this is good as it keeps it graphical and doesn't get the code involved for the user and in turn makes it a lot easier for the user to input the data themselves. They just put whatever information into the allocated box and the information will get added to the code. It also allows the program to run smoothly.

package GraphicalExample;
import javax.swing.JOptionPane;

public class GraphicalExample {

    public static void main(String[] args) {
        String yourName;
        yourName = JOptionPane.showInputDialog("What is your name?");
        System.out.println(yourName);
        JOptionPane.showMessageDialog(null, "Your name is " + yourName);



Above is an example of me creating a simple graphical program using a procedural language (Java). As you can see all the program does is let you input you're name and then shows you what your name is in another window.

In my opinion I think that Event Driven Languages such as Visual Basic is better for graphical applications as it has a lot more functionality options, There is a graphical way of coding (Drag and dropping buttons and other tools etc.) It is also more intuitive.

Modular Elements are Important (M1)

Modularity is when you split your code up into separate manageable pieces. Making it easier to read, follow and understand. Doing this is important if you aren't the only person working on the program as anyone else will be able to see what does what, when it does it and where. More specifically Modularity separates code into functions and procedures. each module that it makes performs one function and contains all the source code to perform that function.

Modularity is a solution for the problem with large programs as it allows you to debug a lot easier as you can find the issue quickly. By breaking the program into modules that perform clearly defined functions you can find the source of the problem quickly and easily.


Here is an image example of modularity taken from a program that creates attributes of a human being. As you can see the methods which makes the attributes are split (Making each attribute in it's own method instead of all in one) This makes the code easier to read and it will be easy to find any problems it may have.