3 ms·
> and the worst have died away (things like goto and classical inheritance) What's so wrong about classical inheritance, and how it died away while being well-
by wolvesechoes 7mo ago
> and the worst have died away (things like goto and classical inheritance)
What's so wrong about classical inheritance, and how it died away while being well-supported in most popular programming languages of today (Python, C++, Java, C#, TS, Swift)?
- Someone 7mo agoInheritance has its uses, but is easily overused. In a sense, it’s like global variables. About every complex program [1] has a few of them, so languages have to support them, but you shouldn’t have too many of them, and people tend to say “don’t use globals”. [1] some languages such as classical Java made it technically impossible to create them, but you can effectively create one with class Foo { public static int bar; } If you’re opposed to that, you’ll end up with making that field non-static and introducing a singleton instance of “Foo”, again effectively creating a global. In some Java circles, programmers will also wrap access to that field in getters and setters, and then use annotations to generate those methods, but that doesn’t make such fields non-global.
- wolvesechoes 7mo ago> Inheritance has its uses, but is easily overused. This I can agree with, but it is far from being "worst pattern". Everything can be like salt.
- Someone 7mo agoYes, but inheritance used to be like salt. That’s why it, like “goto” and global variables, got so much attention.