Caveman
link
fedilink
104M

Using classes is nice tbh. Using inheritance usually isn’t. Inheriting from inherited class should be forbidden.

Inheriting from inherited class should be forbidden.

so an interface with state?

Caveman
link
fedilink
14M

Those are nice. Services that manage data are an example. Having the class also declare how to interact with the data is nice.

My most OOP pattern I like using is implementing an interface with an abstract class for “standard” implementation. Then implement abstract methods for a concrete thing.

I learnt Caml in the 90s at university, I was completely lost, in Prolog too.

JoYo
link
fedilink
English
44M

C++ classes are fairly optional but if you’re already using cpp then it likely wasn’t your choice and neither will the choice of OOP.

Yeah, I like the sweet spot that C++ is in. It can do anything C can but then you have classes and STL and all that on top of it.

JoYo
link
fedilink
English
24M

once i learned about defer it became a hard requirement. cpp kinda gives me that but other c like languages do it better.

Yeah, I wish C++ had function/scope epilogs and labeled loops/breaks, too. Those are the cases where the “never use goto” rule can be broken to make better code than adding all of the code that would be required to handle it the “right” way (setting up early exit flags and if statements after each level of nested loop to check the flag).

Interfaces are great.

Inheritance is often a sign that the previous developer didn’t understand interfaces.

Scrubbles
link
fedilink
English
234M

Broad generic claims like that tell me more

Yep. I’m old, cranky, and prone to broad statements to get reactions.

That said, for any of you all that love inheritance, I’m judging you so hard. So hard. Very judged. I probably hate your code, and your friends’ code, and your last teacher’s code. Especially your last teacher’s code.

Prefer composition over inheritance. Though that doesn’t mean inheritance has no place in programming.

deleted by creator

I used to think I was just a fanboy. But as time went on and I gained more and more experiences, I’ve only become all the more sure that ANSI C is the only language I ever want to write anything in.

Jears
link
fedilink
64M

I was the same, but I recently gave zig a try, it’s lovely to write.

Managed to segfault the compiler though, so maybe not quite ready yet.

Just give me interfaces and composition tbh

OOP is nice. Why do people hate it?

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.

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

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?

Man thanks for sharing the fizz buzz link.

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.

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.

It seriously gets in the way of just winging it.

Multiple inheritance

Ephera
link
fedilink
194M

Because of inheritance.

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

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

“extends”

Polymorphism just goes over my head.

@sparkle@lemm.ee
link
fedilink
Cymraeg
1
edit-2
4M

I like polymorphism. Having to have a hundred differently named functions or structs or something that do the same thing but slightly differently in Rust is annoying as hell. Especially with all the underscores you have to type… If Rust were more functional though it’d make that problem go away pretty quickly.

whoareu
link
fedilink
14M

It’s not that hard however I think it’s absolutely useless and doesn’t add any value to the code.

Joenocide Biden
link
fedilink
English
04M

GOOPs and CLOS exists in functional programming languages. Just saying.

Common Lisp isn’t a functional programming language. Guile being based on Scheme is closer, but I’d still argue that opting into OOP is diverging from the essence of FP.

Inheritance makes complicated objects that would otherwise be impossible possible, but it only works if you know those objects really well. The problem is people write ridiculously complicated mystery objects in libraries and no one knows what’s going on anymore.

that, and that its often not the best use of time to map out the entire project structure in uml before u even write a method…

Tho, C# is statically typed so you can look at the available methods any one library has at any time in the IDE

Springboot is very confusing. The inheritance tree is insane, they created a class for everything, which I get… But it is so hard to understand the whole scope their design.

Just use C

It’s called Go

You spelled Elixir wrong.

Excuse me if I don’t appreciate when the compiler adamantly refuses to do its job when there’s one single unused variable in the code, when it could simply ignore that variable and warn me instead.

I also don’t enjoy having to format datetime using what’s probably the most reinventing-the-wheel-y and most weirdly US-centric formatting schemes I have ever seen any programming language build into itself.

Objects are fine.

OOP sucks.

deleted by creator

palordrolap
link
fedilink
314M

This has bell curve meme vibes. I’m just not sure what the middle guy would be saying.

He died of XML factory injection pattern exposure.

If only he had a briefcase of XSLTs to make sure the XML was safe first.

ThyTTY
link
fedilink
224M

It would say Prototype­Filter­Stub­Facade­Bridge­Decorator­Task­Request­Map­Event­Exporter­Info­Model­Request­Iterator

I’m just not sure what the middle guy would be saying

“I hate inheritance! I hate inheritance! I hate inheritance! I hate inheritance!”

But well, inheritance goes brrrrrr.

We all get disappointed when we don’t inherit anything useful…just a garage full of confusion

Inheritance starts to suck > 1 level deep. Multiple inheritance starts to suck at the point people discuss adding it to a language, or a few femtoseconds after the big bang, whichever comes first.

Uh… from Caml? Because OCaml’s object support is the least surprising part of the language.

modules >>> classes, anyway.

Create a post

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

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.48K Posts
  • 32.6K Comments
  • Modlog