2 ms·
I like to think of it as a language that gives you some of the developer reasoning ability of an OO language - data & behaviour encapsulation - without the over
by Cthulhu_ 4y ago
I like to think of it as a language that gives you some of the developer reasoning ability of an OO language - data & behaviour encapsulation - without the overly complicated push for lasagna code that e.g. Java tries to teach you.
No dog extends animal, cat extends animal, duck extends animal hierarchy, but a "bark" method that only dog and cat implement.
No "everything is an object", you get to decide what goes on the stack vs the heap based on your own insight. But also no pointer arithmetic footgun.
- kaba0 4y agoAn object has nothing to do whether it is allocated on the stack or the heap. C++ has had stack-allocated objects for decades. Also, favoring composition over inheritance has been a major mantra of Java since forever.
- fabian2k 4y agoC# is a clearly object oriented language, and you can decide what is on the stack and on the heap. And while inheritance is a very prominent feature of object oriented languages, it is not the only option there. I think the way those languages are taught over-emphasizes inheritance, but there are plenty of arguments today around preferring composition. So I don't think this is an inherent property of the languages, they allow you to use inheritance but you're not forced to used it everywhere.