top of page
  • Writer's pictureTiffany Silva

All you need to know about Object Oriented Programming Concepts.

Updated: Aug 23, 2021


Basic Concepts of OOP
Basic concepts of Object Oriented Programming, Objects are created out of a class.

Knowing the concept of object oriented programming is very important to any programmer. As a fresh software engineering graduate, this is one of the most common questions that is asked. So what is object oriented programming?


In simple terms, object oriented programming is a software design concept where programs are organized around objects instead of functions and logic.


The basic concepts of OOP are classes and objects which represents real life entities. A class can be defined as a blueprint that describes states/behaviors and an object can be defined as an instance of a class which consists of unique behavior and attributes.

 

What are the principles of Object Oriented Programming?

Principles of OOP
Principles of Object-Oriented Programming

There are four principles of object oriented programming,

  • Encapsulation

  • Polymorphism

  • Abstraction

  • Inheritance

Encapsulation

Encapsulation is said to be achieved when the state of the object is kept hidden/private inside the class. Meaning, other objects outside of the class cannot access the states directly but can be achieved with a limitation using public functions. Outside objects cannot directly manipulate the states of the object.

Encapsulation Example
Encapsulation in Object Oriented Programming

Abstraction

Abstraction is a concept said to be a natural extension of encapsulation. When it comes to object oriented design, programs get extremely large because of this, programs are often difficult to maintain for years. Abstraction is the concept used to address this problem.

Abstraction is simply exposing the internal mechanism that are only relevant for the use of other objects which means other internal implementation details should be hidden.

Abstraction can be achieved using abstract classes or interfaces.


Abstraction Example
Abstraction in Object Oriented Programming

Inheritance

When it comes to programming, the same logic is often duplicated in multiple instances. This results in unmanageable and messy code. Inheritance in OOP is said to be used to overcome code duplication. This can be achieved by separating the common logic to a specific class which is known as the parent class and extend it by other classes which is known as child classes who wishes to use the same logic or to further improve it. So this child class can use the fields and functions of the parent class and add more functionality as well.


Inheritance concept
Inheritance in Object Oriented Programming

Polymorphism

Polymorphism in greek refers to "many shapes" . Hence, polymorphism is said to be a concept where objects could take on more than one form depending on the context. Polymorphism has two types,

  1. Overriding- Sub classes replacing the implementation inherited from the parent class by implementing their own implementation in a method with the same name, same signature, same return type and same number of parameters.

  2. Overloading- when there are methods with the same name but different signatures. This typically is decided during compile time.

Polymorphism example
Polymorphism in Object Oriented Programming

 

In conclusion, Object Oriented Programming is a key software design concept in programming. The use of object oriented design in code will allow code reusability, maintainability and readability as well. Mastering object oriented programming will allow you to develop and implement efficient and effective programs.


Hope you guys liked my article, please feel free to share your thoughts and comments. :)


92 views0 comments

Comments


Posts

bottom of page