What is object oriented programming?

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.

OOP concepts and ideas

Because objects can be given attributes and behaviours, and be organised into classes, it makes this method of development much more efficient for collaborative working. For example, projects can be grouped together based on matching classes and attributes, with developers focusing on the relationships between objects rather than the objects themselves.

Additionally, objects can be granted the same properties and behaviours of parent objects, meaning less needs to be done to these superclasses because they’re inherently the same, just with a different relationship. Parent and child classes are also known as subclasses or derived classes and this inheritance of classes allows OOP code to be used over and over again, achieving what is known as runtime polymorphism.

Polymorphism refers to the ability for tasks to be achieved in multiple ways, so OOP can choose the specific called function at runtime, depending on the context of the current scenario. 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.

Abstraction is where a programmer can conceal everything except the relevant data about an object in order to decrease complexity and increase efficiency. In other words, representing features without including background details or explanations.

Encapsulation is a concept where data and methods that work on that data are bundled together in one unit. It’s used to conceal values or state of a structured data object inside a class, preventing unauthorised direct access to them.

Abstraction and encapsulation may sound similar, but the two differ in that abstraction hides unwanted details while giving out the most essential details, while encapsulation means hiding the code and data into a single unit.

 

Start typing and press Enter to search

Shopping Cart

No products in the cart.