DEV Community

Frank Puffer
Frank Puffer

Posted on

OOP is great! And here is why!

My first impression of OOP, many years ago, coming from C programming: Cool, let's put everything into a class and declare some attributes. These are like global variables but without the bad smell. No more need to pass too many arguments around.

It took me a few years to find out that this is not the real benefit of OOP.

Unfortunately, when looking at OOP code today, many developers still seem to adhere to this mindset.

Unfortunately this is how OOP is still being taught at schools.

Top comments (2)

Collapse
 
theelectricdave profile image
David S.

What was the benefit?

Collapse
 
fpuffer profile image
Frank Puffer

There are cases where it makes sense to encapsulate stuff in objects as opposed to functions. These are probably the ones where you can come up with a really good (descriptive) name for the class.

There are probably even a few domains where inheritance makes code easier to understand, sometimes one has to deal with these strictly hierarchical structures. UI component libraries might be an example but I am not sure.