Since its inception in the late 1960s, it has been nearly impossible to find a programming language that hasn’t been influenced by OOP.
What is an object anyway?
An object can be simply thought of as anything with properties and or behaviors. For a more illustrative example, we can look at basketballs.
Basketballs have many properties, like their
number of bounces,
location. They also have behaviors, like
deflate. This is a good candidate for an object, since it is a “thing” that has properties that can be different.
Objects vs Classes
One common mistake that many first-time programmers make is not understanding the difference between an object and class. While somewhat similar, it is very important that a programmer understands the difference.
A class is a template for an object, and thus, an object is an instance of a class. In other words, a class is like a blueprint for a building while an object is the building itself.
Classes, not Objects
I was being slightly misleading when describing what an object is at the beginning of this tutorial. When writing code in an OO (object orientated) language, you’re writing code that describes a class, not an object.
The idea behind object orientated programming is that you are to create instances of classes that all have different property values, but have the same ways of interfacing.
The end result of this paradigm is generally less code written than other programming paradigms because it inherently increases code reuse.
After learning about the ideas behind OOP, you can learn about how to actually code OOP in Java with my tutorial on Object Orientated Programming in Java.