Login
Password

Forgot your password?

Concept of Object Oriented Programming

By Edited Nov 13, 2013 0 0

What is Object Oriented Programming?

The simplest way to explain the concept of Object Oriented Programming is as follows:

OOP is a way to design software in order to make it better able to model the natural world.

What does this mean? OOP is just a way to program things to follow natural patterns such as abstract relationships (Animals consist of Tigers, Elephants, and Lions etc.), guaranteed functionality (i.e. all animals have an "eat" or "poop" function), and attributes (Elephants have trunks). All these descriptions of the natural world using the concept of object oriented programming revolve around a central unit of functionality called an Object. Programmers create objects by making a text file that contains a description of the object and methods that the object is able to perform, all in a standard format that obeys the rules of the language used. The following is an example of this written in perhaps the most popular OOP language, Java:

public class  Tiger{
    //Variables
    private String name;
    private int weight;
    private String gender;
 
    //Methods
    public void growl(){
        //Growl code
    }
    
    public Poop eat(Food f){
        Poop p = new Poop();
        //Eat code that converts Food to Poop
        return p;
    }
}

This code is mostly self explanatory if you understand that this object is basically a simple blueprint of what a Tiger would be. Notice that the "class" (blueprint) of Tiger is defined here and all descriptions of it exist within the curly braces following "public class Tiger". There are two types of descriptions within it: attributes such as weight and gender, and methods such as growling and eating. In Java's conventions, anytime you see something with a capitalized first letter, it is an Object. Here we use a few other objects, String, Food, Poop. The latter two are not part of the Core Java language and will be defined in the same format as Tiger in a separate file (just imagine how ridiculous the Poop class would be! Who said OOP isn't fun?). Anything following "//" is a comment, and is ignored my the language. Finally, all the words in blue are called "reserved" words and cannot be reused as a new class name, for example.


If theres anything you should take away from this, it's that OOP languages beautifully model the natural world. The opposite end of OOP languages is straight  bytecode, which is essentially endless streams of zeroes and ones. In the end, all OOP languages are converted into bytecode because a 0 and a 1 are the only two "words" a computer can speak. Which do you think is easier to use however? For this reason, OOP is extremely popular. Just remember, like anything else, if the tool achieves the same result with less effort, then it will be more popular.

 

Why is OOP used?

Simply put again: because it is easy to use. This is a very common theme in programing; every new framework or API that is released aims to automate work that was previously done so that you only need to call one method instead of two or three. This is very useful for companies who hire developers to create software solutions because if the code that is used to create the software is simpler and more effective, then the developers need to work less to create the same product. When they work less and achieve the same result, the product is released or implemented not only faster, but cheaper. If you are in the software industry, try to notice this trend; architects choose frameworks and languages based on the ease of use and flexibility, while managers follow projected man-hours. Usually in contracts for software solutions you are awarded a certain amount of money, and how effectively you finish the work determines how much residual money you pocket.

Bottom line: OOP makes life easier for everyone.

Advertisement

Comments

Add a new comment - No HTML
You must be logged in and verified to post a comment. Please log in or sign up to comment.

Explore InfoBarrel

Auto Business & Money Entertainment Environment Health History Home & Garden InfoBarrel University Lifestyle Sports Technology Travel & Places
© Copyright 2008 - 2016 by Hinzie Media Inc. Terms of Service Privacy Policy XML Sitemap

Follow IB Technology