Object Oriented Programming


What was the first thing that comes to your mind when heard object-oriented programming? In my early days as programmer I always thought it would be writing a code that start with a class. For example:

class Dog
public $name;

public function __construct()
# code...

public function setname(string $name = '')
# code...

public function getname()
# code...

And that it should have a properties, constructor, setter and getter but this basic concept was not really clear. Everything for me was just to follow that rule, that code should be written that way. This concept was first introduce in college during programming 2 subject in my 2nd year. We used java programming language back then for this subject, but I never really have a deeper understanding for what it is. For me it was just some other kind of coding approach and should be written with a class.

And as i remember we we're told that the advantage of object-oriented programming is re-usable. But on my mind, what's the difference if i have a function like:

function get_dog_name()
return "Diggie";

And call it many time as get_dog_name()?

In this article I will walk you through understanding the object oriented programming.

Original Conception

Object-oriented programming (OOP) can be trace back in the late 1950s and early 1960s at MIT. OOP was derived from sketchpad created by Ivan Sutherland in 1960-61. The notions of "object" and "instance" (with the class concept covered by "master" or "definition") was defined in the glosary of his sketchpad thesis.

The idea of object oriented programming was coined by Alan Kay when someone asked him what he was doing and in response he said.

It's object-oriented programming.

Alan Kay has a background in Biology and Mathematics so he thought of the concept of objects being like biological cells and/or individual computers on a network, only able to communicate with messages. So it was intended for messaging from the beginning.

His math background tells him that these objects could have algebra associated with it. Polymorphism came later. His original experiments with the architecture were done using a model adapted from van Wijngaarten's and Wirth's "Generalization of Algol" and Wirth's Euler. Both of these were rather LISP-like but with a more conventional readable syntax.

He didn't understand the monster LISP idea of tangible metalanguage then, but got kind of close with ideas about extensible languages draw from various sources, including Irons' IMP.

Then later he finally understand LISP and then using this understanding to make much nicer and smaller and more powerful and more late bound under-structures.

Another big influence was Carl Hewitt's PLANNER..

Modern Day Object Oriented Programming

Wikipedia as the time of this writing defined OOP as:

A programming paradigm based on the concept of "objects", which can contain data, in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods).

Basically it's a representation of an object and this object holds a data. Say for example you are in some beach and you see a stone beside you and you picked it up, that stone object can be analogous to an object as described in object oriented programming. It's like picking up that stone and use it to represent data.

If in your organization you have a president. You can use that stone you picked to represent as president and you could write the president name somewhere in that stone. Now this stone holds some information about the president. It has now a name property associated to it. You can do so with other persons. This was the most basic idea but there is more about oop.

Class-based and Prototype-based

Depending on what programming language the implementation of OOP can be a class-based or prototype-based. For example php, support class based programming while ruby support prototype based. Other languages support both for example javascript.

One example of class is the code above, in the introduction.

In class-based languages the classes are defined beforehand and the objects are instantiated based on the classes. If two objects apple and orange are instantiated from the class Fruit, they are inherently fruits and it is guaranteed that you may handle them in the same way.

In prototype-based languages no classes exist. The prototype of an object is just another object to which the object is linked. Every object has one prototype link (and only one). New objects can be created based on already existing objects chosen as their prototype.


As mentioned, an object is a representation of a "thing" (someone or something), and this representation is expressed with the help of a programming language. An object like a cat for example has certain characteristics (color, name, weight, and so on) and can perform some actions (meow, sleep, hide, escape, and so on). The characteristics of the object are called properties and the actions are called methods.

Another name for object is instance or in other words the actual object created based on a defined class because as a beginner before it really confuse me what is instance.

For example:

$eagle = new Bird()

Bird() is a define classification while the $eagle is the actual object or instance that carry the bahaviour, traits and properties defined in Bird class.


A class is a blueprint, or a recipe for an object. Like in real life, a class is a classification of an object like birds, cats. etc. Writing a class you define the object behavior, traits and properties. You can create different objects using the same class, because a class is just a template, while the objects are concrete instances based on the template.


Encapsulation is another concept in OOP where data is being conceal preventing unauthorized parties' direct access to them is called properties and what can be done with the data is called method.

I cited an example of this in an MP3 player in the book that I read. You, as the user of the object, are given some interface to work with, such as buttons, display, and so on. You use the interface in order to get the object to do something useful for you, like play a song. How exactly the device is working on the inside, you don't know, and, most often, don't care. In other words, the implementation of the interface is hidden from you.

In some languages, objects can have public, private, and protected methods and properties. This categorization defines the level of access the users of the object have.


The concept of aggregation is breaking one big object into smaller chunks. Like a computer that consists of keyboards, monitor and mouse.