this post was submitted on 30 May 2024
391 points (94.5% liked)

Programmer Humor

31867 readers
1069 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Asudox@lemmy.world 30 points 3 months ago (7 children)

OOP is nice. Why do people hate it?

[–] Blemgo@lemmy.world 42 points 3 months ago (3 children)

I think the main problem is that people try to shoehorn OOP mechanics into everything, leading to code that is hard to understand. Not to mention that this is basically encouraged by companies as well, to look "futuristic". A great example of this approach going horribly wrong is FizzBuzz Enterprise Edition.

OOP can be great to abstract complex concepts into a more human readable format, especially when it comes to states. But overall it should be used rarely, as it creates a giant code overhead, and only as far as actually needed.

[–] RandomException@sopuli.xyz 6 points 3 months ago

Oh no, the FizzBuzz EE has evolved since I've last viewed it! 😱 Is it bad if it actually reminds me of my current work project's backend (that I haven't written) a bit?

[–] IsoSpandy@lemm.ee 5 points 3 months ago

Man thanks for sharing the fizz buzz link.

[–] seth@lemmy.world 4 points 2 months ago

I got as far as seeing they chose Java and opening the constants file, and immediately executed a strategic withdrawal. I love that people went to this level of detail

[–] Ephera@lemmy.ml 19 points 3 months ago

Because of inheritance.

[–] Valmond@lemmy.world 13 points 3 months ago (1 children)

People (sometimes) use it far too much and in wrong ways.

Like inherit when you could just instantiate, or use a template.

Or when "everything should be a class" was also a bummer (inhetit "run()"), like I'd instantiate "main" twice (cool if it had worked I guess).

Or old code written by "wizards" where they cast cast cast instances onto other classes to use specific behaviour in crazily dangerous manners. And you're the one to "fix it" because it doesn't work well...

Otherwise OOP is good.

[–] zalgotext@sh.itjust.works 14 points 3 months ago

Just like any software design principle, it's understood at a surface level by tons of bad developers who then try and solve every problem with that one principle. Then slightly better developers come along and say "ugh this is gross, OOP is bad!" And then they avoid the principle at all costs and tell everyone how bad it is at every opportunity.

[–] KingThrillgore@lemmy.ml 11 points 3 months ago

Multiple inheritance

[–] PeriodicallyPedantic@lemmy.ca 11 points 3 months ago

There are common traps and employer don't spend money/time to train their devs to avoid them.

SOLID principles are pretty decent but a surprising number of people don't do any of them

[–] vga@sopuli.xyz 4 points 3 months ago

It seriously gets in the way of just winging it.

[–] HStone32@lemmy.world 1 points 3 months ago

If you ask me, the only reason for objects to exist are for preventing stale references. Anything more than this is unnecessary.