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.

Advertisement - Article continues below

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.

Advertisement - Article continues below

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.

Advertisement - Article continues below

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

The case for a marketing content hub

Transform your digital marketing to deliver customer expectations

Download now

Fast, flexible and compliant e-signatures for global businesses

Be at the forefront of digital transformation with electronic signatures

Download now

Why CEOS should care about the move to SAP S/4HANA

And how they can accelerate business value

Download now

IT faces new security challenges in the wake of COVID-19

Beat the crisis by learning how to secure your network

Download now

Most Popular

Microsoft Windows

Microsoft's latest Windows 10 update is causing yet more issues

26 May 2020

Nokia breaks 5G record with speeds nearing 5Gbps

20 May 2020
data breaches

EasyJet faces class-action lawsuit over data breach

26 May 2020