← Back to context

Comment by codethief

5 hours ago

> I.e. expressing a class that can be inherited from as a generic object MyBaseClass<T>, where T holds the "derived" object state (and can itself be generic in turn, thereby extending the type hierarchy)

Interesting approach! Have you used this in larger project (i.e. for a larger type hierarchy)?

I suspect it might at least take some getting used to (readability-wise), plus it might lead to additional boilerplate in case some child "classes" only want to override some methods, but not others. (The parent will have to implement some switching logic.)

Overall I agree, though, I can't think of any OOP use case that could not be covered by this.