Member-only story

The Most Important Concept of Object-Oriented Programming

Forketyfork
3 min readJun 14, 2020

--

Image by Free-Photos from Pixabay

As it grows, any codebase becomes harder to maintain. One of the ways to solve this problem is to use Object-Oriented Programming. There’s quite a lot of sources of information on how to write clean and nicely structured object-oriented code, and they all put stress on different concepts, sometimes even inventing their own.

I’d like to share my view on the matter. The most important concept of Object-Oriented Programming for me is not inheritance, encapsulation, or polymorphism, but the notion of keeping the data and the related code close. The point of this is being able to keep your program structured and traceable. All other properties of OOP are related to this concept.

Encapsulation makes sure the code of one entity doesn’t access the internals of another entity directly but via an exposed interface. All implementation details of an object, including the data fields, are hidden. This allows the code to be compartmentalized and have a traceable behavior.

You may have stumbled upon some critique of the Inheritance concept lately: many issues with the structuring of complicated code are easier solved by composition than by inheritance. This idea has its merit. However, inheritance is not only about inheriting one class from another, but also about implementing and extending interfaces, which…

--

--

Forketyfork
Forketyfork

Written by Forketyfork

Software developer @ JetBrains CodeCanvas. I write technical how-to articles and occasional rants on software development in general. Opinions are my own.

No responses yet