Hacker News new | ask | show | jobs
by fooker 1061 days ago
No, this blocks a fundamental concept of OOP: Liskov Substitution Principle.

The idea is that you should be able to use a derived object anywhere the base one is required.

2 comments

It impairs that principle, yes. But it doesn’t block similar patterns that give you similar end results. Swift has very flexible generics programming and type abstraction that still lets you use it with a little extra work.

Yes, it won’t be as ergonomic as the ideal, but it’s better than many binding solutions from C++ to compiled languages, while providing most of the usability.

Plus the footnote says that they plan to resolve this in future Swift versions.

It does not import the relationship, but you can still model it via protocols.