What is Object-Oriented Programming?

Share on Facebook5Share on Google+8Tweet about this on TwitterShare on LinkedIn10Pin on Pinterest0Share on Tumblr0

 

Whether you’re a coding beginner or a parent learning about different programming languages, you’ll come across the phrase “object-oriented programming” soon enough. Most popular languages are object-oriented (or OOP), like Python, Java, and many more. So what is OOP? Many definitions out there are too technical or confusing. Let’s break it down.

 

Making things simpler

In the good old days, programs were written in “procedural” code, or one long program containing lots of data and logic. As you can imagine, this wasn’t easy to read or write. Even computers started complaining (there’s no proof of this, but I’m pretty sure they did).

To simplify things, object-oriented programs break up the program into “objects,” or mini-programs that you can use without having to re-write them. With objects, programming is less code and less repetition.

 

A little help from Steve Jobs

Steve Jobs

 

To understand this concept, let’s use an explanation from Steve Jobs. In a 1994 interview with Rolling Stone, he says:

 

“Objects are like people. They’re living, breathing things that have knowledge inside them about how to do things and have memory inside them so they can remember things. And rather than interacting with them at a very low level, you interact with them at a very high level of abstraction, like we’re doing right here.

Here’s an example: If I’m your laundry object, you can give me your dirty clothes and send me a message that says, “Can you get my clothes laundered, please.” I happen to know where the best laundry place in San Francisco is. And I speak English, and I have dollars in my pockets. So I go out and hail a taxicab and tell the driver to take me to this place in San Francisco. I go get your clothes laundered, I jump back in the cab, I get back here. I give you your clean clothes and say, “Here are your clean clothes.”

You have no idea how I did that. You have no knowledge of the laundry place. Maybe you speak French, and you can’t even hail a taxi. You can’t pay for one, you don’t have dollars in your pocket. Yet I knew how to do all of that. And you didn’t have to know any of it. All that complexity was hidden inside of me, and we were able to interact at a very high level of abstraction. That’s what objects are. They encapsulate complexity, and the interfaces to that complexity are high level.”

 

That’s very helpful, thanks Steve. But when you sit down to start programming, how do you make an object? Let’s look at an example.

 

What’s in an object?

Let’s say you want to build your own car. After you build it, the car will be your object.

First, you start with a class. The class is your blueprint, or the description of your car. The class consists of:

  1. Your car’s characteristics, or attributes. Let’s say our car will be have flowers painted on the sides, and have 5 seats.
  2. The class also describes your car’s methods — the behavior, or what it can do. Let’s say the car will go forward and reverse.

Once we have the class, we can make our object. Let’s call it the Mystery Machine. Now that we have an object called the Mystery Machine, Scooby and the gang can use this object over and over again to solve mysteries, without building it from scratch every time.

 

The Mystery Machine

 

Not sure why they all have to sit in the front, but OK!

So there you have it: a basic definition of object oriented programming. Of course, the best way to learn more is to start programming.

Check out Tech Rocket’s Java courses to learn more and try it for yourself.

James Knutila Editorial Lead
James joined the Tech Rocket team in 2016. He writes about the intersection of technology, design, and education.
, , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *