So, what is an object anyway?
You are probably thinking an object could be defined as a person, place, or thing. If so, school paid off for you, and this is not a bad starting point.
What does this have to do with programming and computers?
Amongst other things, objects in programming can be used to model objects from the real world. Since programs are designed to work and be used in the real world, it helps to be able to mirror reality. Additionally, as we saw in the video, using objects is a useful way of grouping together details. Every sentence in the English language would be excruciatingly long if we couldn’t all recognize words like “refrigerator” or “pizza.” Imagine having to describe either of those in detail every time you wanted to talk about dinner!
Understanding Abstraction
Abstraction serves to hide the complex mechanisms within an object, leaving only the information that we need in order to interact with it. To illustrate this, you could think about an elevator.
If you work in an office building, this may be part of your daily experience. You press either an up or down button and wait for the doors to slide open. Once they do, you walk into a box which has a panel of buttons on one of its walls, and you press the button for the floor you want. When the elevator arrives at your floor, you squeeze past the other people and step out.
Now, there’s more than that to how an elevator works - there’s a pulley system, machinery, electrical wiring, shock absorbers, a security system, and so forth. You may know that in the back of your head, but if you’re like most people, you’d probably have to do a little research to explain exactly how elevators function. To use an elevator, you simply have to understand how to use the right buttons to get where you want to go. In other words, you’ve abstracted out the most salient details and have focused your attention on them. That’s how abstraction works in computer programming, too.
Let’s try another example. In programming, we could create a circle object that automatically calculates the circumference (or perimeter, if you're fancy) and the area of a circle. We tell it “calculate area,” and it spits out a number for us. By no means do we need to remember how you calculate the area of a circle. The object does all the complex stuff for us! All we have to do is use the result.
And that’s what abstraction is: hiding the complicated details, so that we can focus on the useful stuff we want and need.
Summary
Objects can be designed to model real-world things in software.
Objects group together details.
Abstraction means showing only what’s relevant and useful for the person using it.
By hiding all the inner workings of a given object with abstraction, we are able to reduce their apparent complexity.