News for hackers. Stuff that matters.
Re:If Inheritance is so bad, why does everyone use it? by arethuza on Thursday April 11, 2024 @04:07AM (#39999595)
Have you ever seen wildly over-architected OO code where everything seems to be an abstract class and it seems impossible to find out where stuff actually happens?

Inheritance is like a lot specialised tools - it can be useful in some situations but I think those are rarer than supporters might thing. Completely refusing to use inheritance and always using inheritance both seem like extreme views that should be avoided.

Re:If Inheritance is so bad, why does everyone use it? by pyrale on Thursday April 11, 2024 @04:30AM (#39999765)
You haven't lived life to the fullest until you've had to debug an issue in a 12-layer-of-inheritance class with the original call ping-ponging a couple dozen times across the layers and overrides everywhere.

I guess one could say this would be workable with proper tools, but the IDEs just aren't there. Move up a level in inheritance, ctrl-click on a call? It was overriden somewhere in the hierarchy, but the IDE will send you to the parent-class definition regardless.

Re:If Inheritance is so bad, why does everyone use it? by touisteur on Thursday April 11, 2024 @03:03PM (#40005613)
I have actually seen one (1) beautiful C++ codebase with very good use of OOP and multiple inheritance, and author (I was his intern) painstakingly taught me about inheritance and its good uses. He used Design and Evolution of C++ (!) as a bludgeon. It was 2006.
Re:If Inheritance is so bad, why does everyone use it? by ben7799 on Thursday April 11, 2024 @04:00PM (#40006201)
The person who wrote that would have made your life miserable if they had architected it 5 other different ways as well.
Re:If Inheritance is so bad, why does everyone use it? by Capricorn2481 on Friday April 12, 2024 @09:04PM (#40019400)
Disagree. Some things are just easier to get right than inheritance.
Re:If Inheritance is so bad, why does everyone use it? by touisteur on Thursday April 11, 2024 @02:57PM (#40005562)
Feels like that time my physics PhD student girlfriend asked me "hey you're a programmer, right" and I was one until I discovered ROOT and suddenly I lost taste for life and anything related to Computers.
Re:If Inheritance is so bad, why does everyone use it? by esafak on Thursday April 11, 2024 @05:51PM (#40007210)
Did you become a reclusive mathematician like Perelman or Grothendieck??
Re:If Inheritance is so bad, why does everyone use it? by touisteur on Friday April 12, 2024 @07:19AM (#40011324)
More like changed girlfriends...
Re:If Inheritance is so bad, why does everyone use it? by kaba0 on Thursday April 11, 2024 @04:50PM (#40006679)
Sure, but I have also seen C code where random structs with function pointers are passed to god-knows-where, and I will take inheritance over that any time of the day.
Re:If Inheritance is so bad, why does everyone use it? by bluefirebrand on Thursday April 11, 2024 @07:28PM (#40007911)
This is every OO code I've ever seen, honestly
Re:If Inheritance is so bad, why does everyone use it? by TheBigSalad on Friday April 12, 2024 @01:54PM (#40015701)
I've seen that same problem sans a deep inheritance hierarchy.