Does Liskov Substitution Principle also apply to classes implementing an interface?
问题 LSP states that classes should be substitutable for their base classes, meaning that derived and base classes should be semantically equivalent. But does LSP also apply to classes implementing an interface? In other words, if an interface method implemented by a class is semantically different from what user expects it to be, would this be considered as a violation of LSP? Thank you 回答1: No It only applies to subtypes. See the Wikipedia article for a brief summary. If you have a class B that