Featured

Object Oriented Programming Introduction

Object oriented programming (OOP) is an approach that views a problem in terms of object. It modularizes the program by creating partitioned memory area for characteristics and behaviour of the objects involved. Every object has its own characteristics and behaviours. For example, characteristics of some car could be: orange in colour, hatchback etc. and behaviour could be: moving, carrying passengers etc. In that case, even human beings are objects because human beings have characteristics such as height, weight, hair colour etc. and behaviours like walking, talking, dancing etc. 

Objects are everywhere and viewing the objects as objects while solving a problem will be a much effective approach than writing a list of instructions (or actions) for the computer to follow (like in procedure oriented programming).


OOP means building objects in the program. Every object represents a real life object.
For instance, consider the lock in your mobile phone. It opens only when the right key (password) is entered. While designing the mobile phone, the coders would've thought of the mobile phone lock as a real lock that can click open only when the right key is inserted. This is how OOP approach works. 

But, why OOP?

Some programming languages such as COBOL, FORTRAN, C are commonly known as procedure oriented programming (POP). Although POP is the conventional approach of programming, it has certain drawbacks.

Drawbacks of Procedure Oriented Programming

Drawbacks/ disadvantages/ demerits/ cons of POP are as the follows:
  • POP basically consists of writing a list of instructions for computer to follow and organizing these instructions into groups known as functions. In a multi-function program (program with multiple functions), most of the functions share global data which are freely available to all functions. Although this freely available data are easily accessed by any function, they are more vulnerable to inadvertent change by a function. In a large program, it is very difficult to identify what data is used by which function (data move openly around the system from function to function). It is possible that the data may be changed accidentally or deliberately. Therefore, there is no security of data in procedure oriented programming.
  • Whenever data structure is required to be changed, all the functions using that data must also be changed. So, procedure oriented programs especially for complex applications are extremely difficult to modify and maintain.
  • Procedural approach does not model real world problems very well. For instance, a vehicle is an object which is capable of moving in real world. However, the procedural programming paradigm would just be concerned about the procedure of doing things i.e., the procedural programming paradigm would just think of the moving part and not the vehicle. It emphasizes on procedures rather than data.

Examples of Object Oriented Programming Languages:

  • C++
  • C #
  • Java
  • Python
  • PHP
  • JavaScript
  • R
  • Ruby- is a pure Object Oriented Programming Language
  • Visual Basic
  • Scala
  • Delphi
  • Perl etc.

Differences between Procedure Oriented Programming (POP) and 

Object Oriented Programming (OOP)


Procedure Oriented Programming (POP)

Object Oriented Programming (OOP)

  • In POP, program is divided into small parts called functions or procedures and each function or procedure has a clearly defined purpose and interface to other functions or procedures in the program.

  • In OOP, program is divided into small parts called objects that correspond to a real world entity.

  •  In procedural paradigm, data and functions are loosely coupled because importance is not given to data but to functions as well as sequence of actions to be done.

  •  In object oriented paradigm, data and functions are tightly coupled to constitute objects. Importance is given to the data rather than functions because OOP works based on real world

 

 

 

 



 



Comments