Object-Oriented Programming

Bradley Nice
2 min readApr 23, 2021

by Bradley Nice, Content Manager at ClickHelp — all-in-one help authoring tool

Object-Oriented Programming, also known as OOP, is a computer programming model for building software based on classes and objects. It organizes software design around data (objects), rather than functions and logic. A class is a coded template for representing values of data and implementations of behaviors. An object is an instance of a class. There are 4 pillars for Object-Oriented Programming:

  • Encapsulation
  • Abstraction
  • Inheritance
  • Polymorphism

Encapsulation means hiding sensitive data from users, which can only be accessed via getters and setters. Encapsulation is achieved when each object keeps its state private, inside a class. Other objects don’t have direct access to this state. Instead, they can only call a list of public functions — called methods.

Abstraction means hiding certain details and only showing essential information to the user. Applying abstraction means that each object should only expose a high-level mechanism for using it.

Inheritance means that a class can inherit the values and behaviors of another class. Objects are often very similar. They share common logic. But they’re not entirely the same. So to reuse the common logic and extract the unique logic into a separate class we apply inheritance. It means that you create a (child) class by deriving from another (parent) class. This way, we form a hierarchy.

Polymorphism means “many shapes” in Greek, in our case, it means that we have many classes related to each other through inheritance. Simply put, polymorphism gives a way to use a class exactly like its parent so there’s no confusion with mixing types. But each child class keeps its own methods as they are.

The most popular OOP languages are:

  • Java
  • JavaScript
  • Python
  • C++
  • Visual Basic .NET
  • Ruby
  • Scala
  • PHP

OOP code may be more complicated to write and take longer to compile. That’s when alternatives step in. Alternative methods to OOP include:

  • functional programming
  • structured programming
  • imperative programming

And most advanced programming languages give developers the option to combine these models.

What programming model do you use?

Have a nice day!

Bradley Nice, Content Manager at ClickHelp.com — best online documentation tool for SaaS vendors

--

--

Bradley Nice

Content Manager at https://medium.com/level-up-web 👈. I write about web design, web development and technical writing. Follow me on Twitter and Facebook