logoalt Hacker News

bedobi01/22/20251 replyview on HN

I see no need for inheritance there, that can and should be done using interfaces

eg in the contrived example I gave, any of all three of the User, Student and Employee can implement the interface (and if needed Student could simply delegate to its internal User while Employee could "override" by providing its own, different implementation)


Replies

tsimionescu01/22/2025

What difference do you see between implementing an interface and inheriting from a class, that makes one good and the other bad?

I'm asking beyond the arbitrary distinctions that some languages like Java or C# bake in.

show 2 replies