Select Page
object oriented programming - school of programming

Object Oriented Programming: A Breakdown for Beginners

Object oriented programming (or OOP) is a collection of objects (data) and patterns of their interactions around data, or objects, rather than functions and logic. In other words, data and logic are encapsulated into objects and object oriented programming helps break down large programs into smaller and reusable parts.

Object Oriented Programming languages include C#, Java, Python, C++, Visual Basic .Net and JavaScript. Apple co-founder Steve Jobs explained object oriented programming in this jargon-free breakdown.

Why Do We Need Object Oriented Programming

Object oriented programming focuses on the thinking process the implementation of what the developer wants to manipulate — rather than the logic required to manipulate them. 

Object Oriented Programming Benefits

  • Scaleable and upgradable — all data can be kept in one place.
  • Security — using encapsulation and abstraction, complex code is hidden, maintenance is easier and protocols are protected.
  • Productivity — makes it easy to maintain and reusable code.
  • Modularity — encapsulation enables objects to be self-contained, and provides a clear modular structure for collaboration and troubleshooting code.
  • Reusability — components can be reused through inheritance, the same code can be adapted and modified multiple times.
A little programming humor!

Basic Principles of Object Oriented Programming

  1. Abstraction: Do you know how to ride a bike? What do you do?  Start pedaling and you’ll hear the gears start to engage. You keep pushing with your feet to go faster, or you can pedal backwards to slow or stop.  Just knowing the basics of the pedals, breaks, and gears got you started.

    Do you need to know all the names of the parts to ride the bike? No, you can  ride the bike without technical knowledge. This is Abstraction, the process of simply telling the essential details and hiding the background details. Objects only reveal internal mechanisms that are relevant for the use of other objects, hiding any unnecessary code.
  2. Encapsulation: Have you ever had a bad cold?  Did your doctor prescribe medicine where the pill was clear but you could see the little pellets inside? This is encapsulation.

    This principle states that all important information is contained inside an object and only select information is exposed. In encapsulation, the data is stored inside. A benefit of the capsule is that it saves the content inside from any outside misuse and damage. Encapsulation is the process of binding together data and functions that manipulate the data and keep it safe from outside interference.
  3. Polymorphism: This is the ability for a message to be displayed in multiple forms.  Think about your role in your family. Are you a son, father, husband, or cousin? Depending upon the situation, you are in different roles at the same time. This is polymorphism, the ability of an object to take on many forms.

    Objects are designed to share behaviors and they can take on more than one form thus reducing the need to duplicate code. If you break this down this word, poly: many, morphism: forms.  Another example is fruit, different types of fruit are eaten in different ways. An apple can be eaten with the skin. A banana can also be eaten, but in a different manner from an apple — you must peel it first.
  4. Inheritance: Remember the doctor who prescribed your medicine earlier?  You’ve not improved so your doctor says you need to see a specialist about your sinuses.  All doctors must go through the same training, then they go into their specialized training areas.  All doctors, but different levels of training. 

    This is a basic concept of inheritance, but you get the point. Classes can reuse code from other classes. Inheritance is the ability for one class to be related to another class in much the same way that people can be related to one another. Another example is how children inherit characteristics from their parents. 


Why is Object Oriented Programming Important?  

Scalability, efficiency, reusability, information protection, and easy debugging are all benefits of object oriented programming.  Which one of these items below is  easier to build, modify, and create?

If you guessed the Lego castle, you are correct. Since an object oriented programming approach was used to build the Lego structure, it’s easily modified. The beach sandcastle is harder to maintain and modify because of other elements such as water, people, etc. 

Object oriented programming is convenient for problems which can be solved with relationships between elements, where there’s a known set of methods and processes.

Object oriented programming can also be a lot of work without planning and foresight, additionally it can be damaged due external changes. But object oriented programming doesn’t solve everything, and some problems don’t easily fall into this paradigm. 

Object oriented programming can be used to help manage the size and complexity of your software. It helps to break down the code into smaller, more manageable chunks so that programmers can focus attention on a small piece at a time.


How Do I Learn Object Oriented Programming?

Ultimately, object oriented programming is about organization and saving time. With object oriented programming, you are able to break down monster programs into much smaller pieces of code, and you’re able to reuse sections of code to save time in the long run. 

Object oriented programming is a useful tool for your toolbox. You can start to increase your skills through Udacity’s Intro to Programming Nanodegree and learn the basics of programming with HTML, CSS, Python, and JavaScript with hands-on exercises and projects that demonstrate your grasp of coding fundamentals. Build confidence in your ability to think and problem-solve like a programmer to prepare for high demand tech roles.

Monique Roberts
Monique Roberts
Monique is part of the marketing team at Udacity. When she's not writing, she enjoys photography, traveling to new places, and researching recipes for her next culinary creations!