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).
How inkjet can transform your business
Get more out of your business by investing in the right printing technologyDownload now
Journey to a modern workplace with Office 365: which tools and when?
A guide to how Office 365 builds a modern workplaceDownload now
Modernise and transform your sales organisation
Learn how a modernised sales process can drive your businessDownload now
Your guide to managing cloud transformation risk
Realise the benefits. Mitigate the risksDownload now