OOP

Object Oriented Programming is a programming methodology that looks at the program in terms of smaller self contained mini programs (objects) that each have their own name, data and logic, and that interact with one another to form a whole application.

 

OOP is intended to make thinking about programming closer to thinking about the real world, where an object’s attributes and behaviours are bundled together. For example, the following represents a real world scenario of 2 people, viewing their shared bank account with one also interacting with a shopping cart.

 

 

This could be represented by considering each individual item as an object, with their own attributes and behaviours:

 

OOP utilises a technique of defining a construct known as a class which acts like a template / cookie cutter to create objects. A class is an advanced form of an abstract data type (as opposed to the basic/primitive data types,  such as an int or char) that allows the creation of objects that behave in a similar manner but have their own individual characteristics.

 

This is in contrast to Procedural programming that basically looks at the program as a long (procedural) list, with all the data / variables defined in one place and all the logic in another. As procedural styled programs grew, they became difficult to manage which led to the uptake of OOP.

 

The process of bundling data with logic, is referred to as encapsulation, which is one of the fundamental features of OOP:

  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorphism

The idea is to take advantage of these features to promote code reuse whilst decreasing code maintenance.

Leave a Reply