Understanding Object Oriented Programming

A Simplified Look at Object Oriented Programming for Beginners

© Vasu Chetty

Jun 25, 2009
Object oriented programming for beginners is an abstract idea that can often lead to frustration. Using real world examples to visualize it in action can change that.

Many beginning programmers find it easy to follow the basic logic behind simple programming techniques, such as if and then statements or arrays and loops. However, when taking the leap to object oriented programming many find it to be too great a stumbling block, an idea too abstract to understand.

Described below is the "Cookie Cutter" method of understanding object oriented programming, a simplification of what can often be an ominous step in learning an object oriented language.

Understanding Classes

First, the cookie cutter itself is called a class. Just as a cookie cutter is an outline that gives the shape to a cookie, so is a class an outline for an object.

A class defines the functions and variables necessary for an object. Also, just as a cookie cutter can come in many shapes and sizes, each class consists of different functions and variables depending upon the project.

Understanding Objects

Next comes the cookie, or what is known in programming as the object. The object is exactly the same shape and size as the cookie cutter, but it is no longer just a shell. Just as a cookie is fuller with dough than a cookie cutter, an object is "fuller" than the class since its variables store real data and can execute functions.

What is Instantiation?

The creation of a cookie, the act of cutting it out, is called instantiation. Programmers learning object oriented programming may recognize this word. The actual act of initializing an object, or cutting a cookie using the cookie cutter template, is an instantiation of the object. Whenever an object is instantiated it runs the Constructor function of the class; basically, it is building the cookie. When an object is destroyed, then the Destructor class is automatically run.

Although the cookies created using the cutter will appear the same, they can each be decorated differently in order to make each unique. This is the same with objects, although they contain the same variables and functions different data can be stored in different objects.

For example, an address book can create a different object for each person stored. Every person is similar in the fact that they have a first and last name, as well as an address and phone number. However, the actual names and numbers for each person are different. Same essential outline, differently decorated cookie.

What is Inheritance? Understanding Parent and Child Classes

Another early concept that beginning programmers will encounter is parent and children classes, associated by the term inheritance. Hopefully this concept is a little easier to understand as it is already using the analogy of genetic inheritance. Just as a child inherits genes from its parents, a child class inherits variables and functions from its parent class.

One example of inheritance can be seen in using vehicles, which can be broken up into cars, trucks, motorcycles, etc. Every vehicle has a make and model, but motorcycles have different components from cars and trucks. So a vehicle class would contain all the variables and functions common to all of them, while the individual classes themselves would contain the variables and functions unique to their type.

Key to Understanding Object Oriented Programming

Some programmers might find it easier to code their object-oriented assignments without using classes at all. This might work for the more basic programs, but these easier assignments are to help them understand the concepts.

Object oriented programming helps to greatly reduce repetition in many assignments and projects, so it pays to understand the concept as quickly as possible. Programmers may find object oriented programming difficult at first, but visualizing the ideas and consistent work will eventually lead them to success and a greater understanding of the topic.


The copyright of the article Understanding Object Oriented Programming in Computer Programming is owned by Vasu Chetty. Permission to republish Understanding Object Oriented Programming in print or online must be granted by the author in writing.




Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo