开发者

Does using virtual methods violates LSP( L part of SOLID principles) or there are some exceptions? [closed]

开发者 https://www.devze.com 2023-01-09 01:27 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_如何学C
Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_如何学C

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 5 years ago.

Improve this question

Does using virtual methods violates LSP( L part of SOLID principles) or there are some exceptions?

Thanks in advance, Saghar Ayyaz


Why do you think that? Virtual methods in themselves are just a mechanism for polymorphism. The Liskov Substitution Principle is a just constraint on how you implement the overrides (and other aspects of descendant classes) in order to get predictable polymorphic behaviour.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号