What are Procedural, Event Driven and Object Orientated Programming

Procedural Programming –

procedural language is a list of instructions telling a computer, step-by-step. In this programming practice developer write line by line code which executes a single action each line. In procedural programming first line of code is executed, then the second, then the third and so on, lines cannot jump from the 1st to the 7th to achieve something it must first complete 1-6 in order to get to the 7th line. procedural programming also focuses on the idea that all algorithms are executed with functions and data that the developer has access to and is able to change.  Procedural programming uses a top down approach to executing codes.  Examples of procedural languages are – BASIC, COBOL, PASCAL, FORTRAN, C and PL1.

Event Driven Programming –

event driven programming is a very popular programming practice and is widely used. if you have a phone, microwave, toaster, fire alarm or a PC you have used this one way or the other. the code will wait for an event which is either a CLICK of a mouse button, start the engine, detect smoke, detect heat on the food or whatever then the program will perform a certain action based on that EVENT. Makes sense yet? The whole process is more complicated that just that but essentially follow the similar idea.  In event driven programming an EVENT LOOP plays a major role. These loops are needed to keep testing the user interface to detect whether anything has happened for example a mouse click or key press from the keyboard.  There are many other types of loops that the programmer will use in many of the tutorials in MOOICT we have explored how to use clicks, key press events, form load events and most important timer events.  Major programming languages that are used to create GUI application all have their own version of event driven programming for example C#, C++, Java, JavaScript and Objective C.

Object Orientated Programming – OOP

OOP languages are very popular and they widely used in various different software applications and games. To think about this simply imagine a airplane it has 300 seats, two wings, 2 massive rotor fans and various controls. Now if we want to break it down we can create objects of those 300 seats and instead of making them one at a time we can design the perfect seat once and then have the program make 299 of them exactly the same way.  In OOP programming this is called creating an OBJECT. That’s the first word in OOP.

To make an object in object oriented programming we give the object various different properties for example we need the height, width, colour, fabrics, padding, cushion, adjustment features etc for the plane seat. All of them can be inside that one object and then we can use the program to add the chair 300 times to the plane job done right, its awesomely simple.

Now you might be thinking about the wings, we all know plane wings are not exactly the same but I didn’t pick the plane example to lose now did I. Lets imagine we make the right wing object in programming including the shape, width, height, flaps, rotor location etc we don’t need to make any changes to that wing object however for the left one we can simple INHERIT the properties from the right wing and change the values as we need to. For example we can keep the width, height, flaps and rotor location but can change the shape to the left one so it’s more suited to the plane. Can you imagine a place with two right wings, that would be impractical and funny.  Inheritance is a powerful feature in object oriented programming, it refers to defining a new class with little or no modification to an existing class. The new class is called derived class and the one from which it inherits is called the base class.

This explanation has taken a simpler approach because we are looking at what it is and what it does here is the technical version –

object orientated programming refers to the creation of reusable software object types and classes that can be efficiently developed and easier incorporated into multiple programs.  Unlike the procedural programming practice which is a top down approach to executing the code OOP is a bottom up approach.

OOP also provides data hiding which improves the programs security, for example you can set public, private, internal and protected label on a class to make sure no one from outside the program can see the inner workings of your program.

In OOP an object presents an entity in the real world (the properties we talked about before).  An OOP program is a collection of objects that interact to solve a task or problem.

Example of object orientated programming languages are C#, Java, Action Script, C++, Objective C, Ruby on Rails and others.



Comments are closed.