DEV Community

Discussion on: How I (re)learned OOP is not a silver bullet

Collapse
 
alexm77 profile image
Alex Mateescu

Remember, inheritance in Java (and probably other languages) is achieved by composition - hence my perpetual confusion when I see the "composition over inheritance" argument. Just add the "super" structure as a field in your "derived" structure in Go and voila! instant inheritance. Well, not really, but close enough for a lot of cases I imagine.

Collapse
 
martinhaeusler profile image
Martin Häusler

Well, that's the JavaScript way of understanding OOP. Except that JavaScript at least traverses the super-chain for you in search for a property or method. Here you would have to do it manually. Doing polymorphic dispatches is also not really possible without language support. I don't want to imply that Go is a bad language, it just removes one of my most familiar tools from the toolbox, which makes me feel uneasy.

Thread Thread
 
alexm77 profile image
Alex Mateescu

What can I say, life begins where your comfort zone ends ;)