Object-Oriented Programming

Published Jun 26, 2021Updated Nov 9, 2023
Contribute to Docs

Object-oriented programming (OOP) is a software development paradigm which encourages sculpting desired entities with properties and methods in named classes to create applications.

OOP relies on two major concepts: the class and the object - these foundational concepts applied in code enable us to build applications.

Classes that have been instantiated in our code become objects that can interact with one another to perform the desired functions of the application. Object oriented programming was created to guide the creation of better software, by achieving easier maintenance and reusability.

Principles of OOP

There are four main principles of OOP:

  • Encapsulation: A desired outcome of organizing code in classes in order to keep things from being mixed with other unrelated bits of code. Encapsulation make it easier to reason about code because of the modularity of code written in object oriented styled classes.

  • Inheritance: A principle which allows an instance of an object to borrow attributes and methods from its parent class.

  • Polymorphism: The ability of the class to be dynamic in its use of class methods so that objects with the same parent class can make use of these parent class methods.

  • Abstraction: A principle that highlights the benefit of hiding complex parts of code from other parts in order to make it easier to reason and make decisions about the code.

All contributors

Looking to contribute?

Learn More on Codecademy