Service oriented.
Service oriented programing only runs when a specific event occurs, this can be seen clearly on a computer, look below for an example:
When the user clicks new folder
A line of code runs that causes a new folder to appear in the designated space
This is an example of service oriented programing.
Service oriented programing can run several services in parallel to one another.
Time driven.
A time driven program in its simplest form is a timer. It runs the code depending on the time, for example google docs which updates based off a timer. This kind of code is often referred to as a timer trigger.
Event handlers.
An event handler is the line of code that is ran when an event occurs, for example when someone presses a button it runs the corresponding line of code. For example:
Pressing the start button in windows
Causes the start menu to open
This is done by the event handler being ran when the event “button press” occured.
Trigger functions.
A trigger function is used to attach the line of code with the event that would trigger it. For example when the internet explorer icon is pressed it knows to run the line of code that opens the internet explorer application.
Events (e.g. mouse, keyboard, user interface).
Events dont always have to be the user pressing a button on screen, every time a user presses a button on the keyboard or mouse there is a line of code that is ran, for example when I press “A” the code is ran to make that letter appear, or if the user was running a program where the keypress “A” was used as a shortcut.
Pre-defined functions.
Predefined functions are functions that are used in java to perform specific tasks that make coding easier for the user. Below is an example of a pre-defined function in Java:
String sName;
sName="Billy";
char cPosition;
cPosition=sName.charAt(0);
System.out.println("The letter at position 0 is " + cPosition);
Here is the pre-defined function charAt, this will find the character at a specific position, in this example the position 0 is being used, in Java position 0 is the first letter of the string, when the program is ran the following text will appear:
The letter at position 0 is B
As you can see the code is correct and the pre-defined function works as it is supposed to.
Another example of a pre-defined function is below also in Java:
String sWord;
sWord="Bacon";
int iLength=sWord.length();
System.out.println("The length of the word is " + iLength);
This pre-defined function .length will find the length of a string and print it out for the user, when this code is ran the following text will appear:
The length of the word is 5
This shows the code is correct and the function works as planned.
Local variables.
A local variable is a variable that can only be used in one specific class, below is an example of a local variable in Java:
public class HelloWorld(
String sHello;
)
The variable sHello can only be used in the class HelloWorld, because the variable was declared inside the class, this can be used when multiple methods are being used in the same program, therefor the same variable name can be used more than once but have different meanings in each method.
(This is the most common form of variable)
Global variables.
A global variable is a variable that can be accessed and edited from anywhere in the program, it is advised to avoid using global variables as it causes errors due to multiple parts of the program attempting to edit this variable at the same time. Below is an example of a global variable in C++:
int g_nX; // global variable
int main()
{
As you can see the variable was declared outside of the main therefor the whole program now has access to this variable
Parameter passing.
A good example of parameter passing is the pre-defined function charAt() as seen before this function allows the user to find the character at the given position, the position is declared within the parameter (). Here is an example of the functioning code in Java (you may recognise it from before):
char cPosition;
cPosition=sName.charAt(0);
The number in the parameter is 0, therefore the pre-defined function will use this data to find the character at position 0.
Modularity.
Modular programming is where the program is separated into smaller chunks (modules) that each perform a certain task, this makes it easier to have interchangeable parts of the programme when updating code, adding or removing features of the programme. Below is an example of how modularity works:
As you can see in the diagram the main program has modules, these modules are parts of the programme that would be interchangeable if the creator wanted the programme to function differently.
Programming libraries.
A good example of a programing library is importing predefined commands into the code, the line of command accesses a programing library to import the commands into the code. A programing library consists of various modules that can be used in programs by inserting them, below is an example of how to access a library in Java:
import java.awt.*;
This is one of the many import commands that comes with Java allowing the user to access these libraries when writing their program
Event driven programming
Event driven programming is a programming paradigm that is used to allow the program to respond to different events and inputs. The flow of this program is determined by the inputs or events that occur, so unlike procedural this program doesn’t run from top to bottom, it will jump to the module that ran when the designated input was given. Event driven programs can interact with the users, this is important for programs that use a GUI for example the Microsoft office applications.