Hacker News new | past | comments | ask | show | jobs | submit login

I'd say that inheritance, with method overriding, is the worst anti-pattern of mainstream OOP, which contains a number of otherwise sound ideas, like encapsulation.

I like the Go's approach to that (taken from Oberon), and the Rust's system of traits.

In one large codebase I saw there was a rule to make classes either abstract (without implementation of key parts), or final. Everything else is done via interfaces and composition.

See https://en.m.wikipedia.org/wiki/Composition_over_inheritance




Oberon is fully inheritance based, with interfaces only later introduced in Oberon.NET (for compatibility purposes with .NET) and Active Oberon.

Go only took the method syntax from Oberon-2, package initialization and unsafe instead of SYSTEM.


Hooray Traits! Love them, they are even in PHP so I can use them in these older apps I maintain.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: