News for hackers. Stuff that matters.
Re:Object-oriented programming for kids [video] by quaunaut on Wednesday October 25, 2023 @11:05AM (#38013607)
I can't agree enough. What other paradigm is so regularly implemented in a way that makes doing it poorly easy(Inheritance), doing it well hard(Composition), and requires a list of caveats so large that it effectively draws down to "only use it in these specific places"?

How does a paradigm like that survive? I might be a fan of functional, but I'm not even saying go that way- stay procedural! Learn your abstractions over time and only build them when necessary.

Re:Object-oriented programming for kids [video] by mcbishop on Wednesday October 25, 2023 @11:48AM (#38014053)
VBA's OOP doesn't have inheritance, so I had to use composition. Now I understand that the constraint resulted in better code.
Re:Object-oriented programming for kids [video] by AnimalMuppet on Wednesday October 25, 2023 @11:54AM (#38014108)
How do implementations of OO make inheritance easier than composition?
Re:Object-oriented programming for kids [video] by BeetleB on Wednesday October 25, 2023 @02:32PM (#38016443)
I think the refrain has more to do with inheritance being heavily promoted as the reason for doing OO in the early 90's till the mid 00's. I believe even Bjarne Stroustrup said if you're not doing inheritance, it's not OO and you should stick to C.

Also, while one can do composition about as easily as inheritance, it still has its warts in languages like C++. If you want to unit test code, it's recommended to use dependency inversion instead of regular composition - there are other good reasons to do DI as well. But when you start coding the same stuff in non-OO paradigms, you realize that it's just much easier - stuff like DI was popularized to get around the flaws of the OO implementation in those languages. The same goes for most OO design patterns.

Re:Object-oriented programming for kids [video] by quaunaut on Thursday October 26, 2023 @12:22PM (#38027843)
The number of languages that only support Inheritance and have no version of Composition(or severely compromised versions) is long. What's funny is how many of them make it easier to perform composition as long as you avoid the `class` keyword.
Re:Object-oriented programming for kids [video] by _a_a_a_ on Wednesday October 25, 2023 @12:22PM (#38014433)
> doing it well hard(Composition),

suggest how this may be fixed

> and requires a list of caveats so large that it effectively draws down to "only use it in these specific places"?

I don't recognise this, can you explain please

Re:Object-oriented programming for kids [video] by nesarkvechnep on Wednesday October 25, 2023 @12:37PM (#38014689)
Design patterns
Re:Object-oriented programming for kids [video] by _a_a_a_ on Wednesday October 25, 2023 @02:23PM (#38016311)
IIRC OO is a design pattern. Just happens many langs support it directly.
Re:Object-oriented programming for kids [video] by quaunaut on Thursday October 26, 2023 @12:25PM (#38027886)
> suggest how this may be fixed

Only allow composition. Allow composition techniques to add state, detect the presence of other composition types, etc.