IT Pro is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission. Learn more

What is object oriented programming?

We look at coding that concentrates on objects rather than actions


Object-oriented programming (OOP) has become one of the building blocks of programming, replacing - or working in tandem with - the concept of procedural programming. Whereas the more traditional idea of procedural programming puts action and logic at the centre, OOP utilises objects and data to produce outcomes.

On the simplest level, OOP focuses on the objects a programmer wants to change rather than the actions needed to make that change. This makes it easier for programmers to run a code analysis and also, because many of the objects are reusable for other projects, the time it takes to develop an application, for example, can be shortened significantly.

The majority of modern programming languages such as C++, Object Pascal, Java, Python use a combination of object-oriented programming, as well as procedural programming where required, meaning OOP has become a very important evolution in the world of development.

Core components of OOP

The main idea around OOP is that it's a more efficient method of software development for collaborative working because it allows developers to place in and sort objects by class, allowing them to look at the relationship between them, rather than the objects themselves.

There are four principles to OOP which are encapsulation, abstraction, inheritance and polymorphism, all of which sound more intimidating than the last but a simple explanation will surely get you on track to a full understanding.

Polymorphism is used when objects need to be used for different things in different contexts. It allows a child class to act like the parent class while also keeping its own methods as they are. Within the polymorphism bracket, there are two types of function: overriding and overloading.

Overriding (also known as run-time polymorphism) is used when two objects have the same method name and parameters (i.e. method signature), but one method is in the parent class and the other is in the child class. Overloading (compile-time polymorphism) happens when two or more methods in one class have the same method name but diverse parameters.

Encapsulation is used when objects in a project need to communicate with each other but have mutually exclusive logics that define them. Encapsulating these objects in their own states means other objects cannot change it unless it's explicitly allowed to.

Abstraction can be seen as an extension to encapsulation, its aim is to only expose the necessary information objects need to interact with it and conceal everything else. Using this principle decreases complexity and allows developers to make changes more easily.

Inheritance is used when dealing with several objects which share a lot of common logic, but each has slightly different unique logics. Using inheritance, developers can easily reuse the common logic and extract the unique logic into a different class to maintain a unique hierarchy, ensuring better accuracy.

Examples of object-oriented programming languages

There are many different languages that use object-oriented programming. Among them are Java (which was developed in 1995 by Sun Microsystems, now Oracle), Python (created in 1991 and emphasises code readability), C++ (which has imperative, object-oriented and generic programming features and is an extension of the C programming language), and Objective-C (which adds Smalltalk-style messaging to C and was the main programming language for OSX and iOS).

Featured Resources

Accelerating AI modernisation with data infrastructure

Generate business value from your AI initiatives

Free Download

Recommendations for managing AI risks

Integrate your external AI tool findings into your broader security programs

Free Download

Modernise your legacy databases in the cloud

An introduction to cloud databases

Free Download

Powering through to innovation

IT agility drive digital transformation

Free Download

Most Popular

Former Uber security chief to face fraud charges over hack coverup
data breaches

Former Uber security chief to face fraud charges over hack coverup

29 Jun 2022
Macmillan Publishers hit by apparent cyber attack as systems are forced offline

Macmillan Publishers hit by apparent cyber attack as systems are forced offline

30 Jun 2022
FCC commissioner urges Apple and Google to remove TikTok from app stores
data protection

FCC commissioner urges Apple and Google to remove TikTok from app stores

29 Jun 2022