3 ms·
This was debated in the 90s , Bertrand Meyer (Eiffel) has a good example how boys and girls would end up sharing rooms on a ski trip if variance is handled inco
by zwieback 8y ago
This was debated in the 90s , Bertrand Meyer (Eiffel) has a good example how boys and girls would end up sharing rooms on a ski trip if variance is handled incorrectly:
https://archive.eiffel.com/doc/manuals/technology/typing/paper/page.html https://archive.eiffel.com/doc/manuals/technology/typing/pap...
It was an interesting time - Java didn't have generics yet and C# didn't exist. OO purists were complaining about C++ and Java implementing subclassing using subtyping but in the end no language really directly supports something like the Liskov substitution principle, which is about behavior and not just substituting function signatures.
- nine_k 8y agoI'm not sure LSP can be formally enforced unless you encode the contracts of each methods and prove they are held. This is probably doable in many cases, but the current tools seem pretty heavyweight, as is the mental burden. Regarding these years, I very much regret that subclassing won over interfaces / traits / typeclasses without inheritance.
- zwieback 8y agoTrue but in statically typed languages we have a lot of options now. It's interesting to see how c# and C++ have developed and what approaches new languages are taking. My own practices have definitely changed over the last 25 years, where I initially used class hierarchies to model my problems I now think in terms of interfaces. Also, with everything being connected I just don't worry about building large monolithic systems composed of class libraries any more.