D1J1T Article Categories:

Programming   Management   Development   Design   HTML   JavaScript   CSS   PHP   MySQL   Database   Server   Audio   Object-oriented Programming   Hosting   Mobile   Social Networking   Java  

OOP Power

Alan Kay, We Thank You!

by D1J1T — in Object-oriented Programming — Updated: Feb 9, 2015 at 1:43 pm

This intent of this article is to provide an overview of the power and importance of Object-Oriented Programming.

A Brief Programming History Lesson

Don't worry, I'm not going all the way back to the punch card days. Before OOP, if writing programs was a bit of a nightmare, updating them was a full on night terror. Most early programming types are linear. The control flow of the program is easy to trace. The problem is that all of the data was stored in the same place. This makes it easy for the programmer to accidentally overwrite or alter variables without their knowledge, causing bugs that don't necessarily rear their ugly heads right away even, amongst other issues.

Why Object-Oriented Programming?

Why do you have cabinets and drawers in your kitchen instead of one huge compartment? It's probably for organization and more specifically the separation of similar objects related to and used in the kitchen.

OOP offers many advantages to other programming types:

  1. Encapsulation: The code and data in OOP are related to a specific object. Let's use a "cat" and a "dog" as examples. When you change the variable "smellsLikePoo = true" for your dog class/file, you don't have to worry about your cat (which has this potential as well, i.e. contains the same variable in its code) smelling badly also. Their specific code is encapsulated, while at the same time they can "inherit" specific traits from say an "animal" super or parent class/file.
  2. Inheritance: You've probably already figured this out. Yes, just like you get specific traits from your ancestors, OOP allows objects to be a subclass of another object. They in turn, inherit the traits, fields (variables) and behaviors (methods/functions) of their superclass or parent. This allows you to write an "animal" class for example that contains variables/traits like height, number of legs, soundMade, color, and weight. Then when you write you quot;catquot; class, you automatically inherit all of these and can use their default definition, or can overwrite/alter without having to worry about making your "ldog" class/file purr.
  3. Polymorphism: This means to take different forms. For example, you cat is a cat, but it is also a feline, and also an animal. In certain cases, your cat object may only need it's animal functions traits, whereas other cases may require the code to be more specifically defined as a quot;catquot; that has claws, purrs, 9 lives, etc.

This real world model is one we can all understand. The advantages listed above save programmers time and allow for better organization of code which leads to quicker updates. They also extend beyond the specific program; they allow for the creation of frameworks/libraries, for code to be shared, altered, re-used, and extended by others.


If you find these articles to be helpful, I could always use another cup of coffee! Social media likes/+1s are also much appreciated. Thanks for reading!

Add Comment to Post: