you can write oop without inhetitance
There’s the camp of those who say that inheritance is synonymous with OOP. I’m not in that camp, but I’d like to see you duke it out with them.
That’s just structs and unions right?
You will still have private/public sections, interfaces (unless you class them as inheritance), classes and instances, the SOLID principles, composition over inheritance. OOP is a lot more than just large family trees of inheritance, a way of thinking that’s been moved away from for a long time.
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.
deleted by creator
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.
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
Multiple inheritance
It seriously gets in the way of just winging it.
If you ask me, the only reason for objects to exist are for preventing stale references. Anything more than this is unnecessary.
Interfaces are great.
Inheritance is often a sign that the previous developer didn’t understand interfaces.
Prefer composition over inheritance. Though that doesn’t mean inheritance has no place in programming.
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.
Just give me interfaces and composition tbh
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…
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.
Tho, C# is statically typed so you can look at the available methods any one library has at any time in the IDE
Why typescript? It allows you to make typesafe compositions
Just use C
It’s called Go
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.
You spelled Elixir wrong.
“extends”
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?
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.
Its a great way to make simple code 300% bigger than necessarily.
Is OCaml going mainstream, hm
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.
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.
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.
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).
deleted by creator
OOP was a mistake!