loading...

OOP is great! And here is why!

twitter logo ・1 min read

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.

twitter logo DISCUSS (2)
markdown guide
 
 

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.

Classic DEV Post from Oct 11 '19

Which unknown/smaller web development blogs do you read? 📖👀

Frank Puffer profile image
Software developer, among other things

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️