What is object-oriented programming?

You've probably come across the phrase object-oriented programming somewhere on the Internet. Or you've heard it's related to languages like Ruby, Python, and Java, but you might mention subclasses and inheritance.

Object-oriented programming, or OOP for short, is far less complex than people think, and its existence makes programming tasks easier. To understand it all better, we first need to go back to the basics of computer programming.

What is OOP?

The heart of programming is creative problem solving, and as with almost everything in life, there are many different ways to do it.

Object-oriented programming is like program, functional or logical programming is just one of many approaches to solving problems called paradigms.

How does OOP differ from other paradigms?

Before OOP arrived on the scene, some of these examples argued that the key to the programming challenge was how to write logic to handle the data in a program. For example, programming USES step-by-step lists of instructions to tell the computer what to do. This works well because it's very intuitive: if you want your computer to do something, you just need to provide step-by-step instructions on how to do it.

However, solutions such as program programming have their drawbacks: they are often time consuming because logically bound code cannot be effectively packaged for reuse, which means that software often becomes complex, difficult to understand, and expensive to maintain. Some programmers began to look for a new Angle to the problem, one that could make the DRYer more efficient.

How does OOP solve this problem?

OOP solves problems by reasoning that what we really care about is defining the data we want to manipulate rather than the logic needed to manipulate it. This isn't as complicated as it sounds: it just means that all of these step-by-step instructions in OOP are executed using objects rather than logic.

Sorting the data this way is a great idea when you think about it: an important part of good programming practice is writing code that is readable and easy to change. If you're working on generic, stand-alone units that can handle all kinds of data, you're more likely to stay organized, minimizing development time and reducing the risk of errors.

What is an object?

The object is the tool we use to make this method work. As the main building blocks of OOP, they contain the information needed to make the data in our program useful.

A very basic example of an object is a person. People may have names, ages and addresses: these are our personal possessions. People can also do some things, such as running, listening to music or eating. These are a person's way of life. They allow our object to do things, and (perhaps more importantly) allow us to manipulate its properties.

A slightly more complex (though perhaps more familiar) example comes from JavaScript, where each component (including functions, strings, and Numbers) is considered an object.

What is grade A?

Let's go back to people. Suppose you want to create several people with the same attributes (name, age, address) and method (eat). We need to be able to easily describe "people" with all the basic attributes and methods many times in a concise and effective way.

This is the heart of OOP: instead of writing out the concept of a "person" every time as if it were logic, we just create a class called a "person" that serves as a blueprint for the properties and methods that everyone shares. . So, our "people" class infuses anyone with a name, age and address, as well as the ability to run, listen to music and eat.

Each person created from our "person" class is called an instance of that class and is treated as an object in our "person" class. Thus, a class is treated as a concept (" person ") and an object as an embodiment of that concept (" Fred ").

What is inheritance?

In OOP, each class is designed and programmed to accomplish one, and only one. This is important because doing so can define subclasses of objects that share some or all of the characteristics of the main class.

For example, if we create three "people" instances -- let's call them "Barack," "Arnie," and "Mr.T" -- they all have "people" characteristics, but the "Arnie" subclass will have its own personal property. For example, he may have more eccentric attributes (fashion sense) and more unusual methods (eating fish) than the other two.

This ability to pass selection properties and methods is called inheritance, and goes to the heart of why OOP is so powerful: it not only speeds up program development, but also means that defined subclass objects are always valid.


OOP is just one of a handful of programming paradigms, each with its own strengths and weaknesses. Quite a few programming languages even use a mix of these paradigms to express themselves and interact with the data.

Leave a Reply

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