从检验的角度重构利斯科夫替代原理

E. Baniassad, Alexander J. Summers
{"title":"从检验的角度重构利斯科夫替代原理","authors":"E. Baniassad, Alexander J. Summers","doi":"10.1145/3484272.3484965","DOIUrl":null,"url":null,"abstract":"In this essay, we explore a new pedagogical framing ofway of pedagogically and teaching the Liskov Substitution Principle (LSP). In addition to, or perhaps even in place of, teaching the specifics of the rule itself, we advocatepropose teaching an operationalised version of the rule: that a subtype must pass its supertype’s black box tests for each of its overriding methods. We leverage the fact that black box tests should be written to capture conformance to a specification without overfitting or checking implementation internalsdetails (as would be checked by glass box tests). A type that violates the rules of substitutability will also fail a potential corresponding black box test for the supertype. Additionally, we argue that the over-strict nature of the classical LSP Postcondition Rule (which has been improved in subsequent work) can be a source of confusion for both instructors and for students learning this crucial concept for the first time. Pleasingly, many of the technical subtleties of this nuanced but important concept drop out naturally when thinking of substitutability via black box tests. Thus we put forward We propose that this test-oriented means of teaching substitutability is a valuable alternative to the classical sense of checking the LSP, with the benefit of being intuitively accessible to students.","PeriodicalId":159099,"journal":{"name":"Proceedings of the 2021 ACM SIGPLAN International Symposium on SPLASH-E","volume":"5 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2021-10-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"1","resultStr":"{\"title\":\"Reframing the Liskov substitution principle through the lens of testing\",\"authors\":\"E. Baniassad, Alexander J. Summers\",\"doi\":\"10.1145/3484272.3484965\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"In this essay, we explore a new pedagogical framing ofway of pedagogically and teaching the Liskov Substitution Principle (LSP). In addition to, or perhaps even in place of, teaching the specifics of the rule itself, we advocatepropose teaching an operationalised version of the rule: that a subtype must pass its supertype’s black box tests for each of its overriding methods. We leverage the fact that black box tests should be written to capture conformance to a specification without overfitting or checking implementation internalsdetails (as would be checked by glass box tests). A type that violates the rules of substitutability will also fail a potential corresponding black box test for the supertype. Additionally, we argue that the over-strict nature of the classical LSP Postcondition Rule (which has been improved in subsequent work) can be a source of confusion for both instructors and for students learning this crucial concept for the first time. Pleasingly, many of the technical subtleties of this nuanced but important concept drop out naturally when thinking of substitutability via black box tests. Thus we put forward We propose that this test-oriented means of teaching substitutability is a valuable alternative to the classical sense of checking the LSP, with the benefit of being intuitively accessible to students.\",\"PeriodicalId\":159099,\"journal\":{\"name\":\"Proceedings of the 2021 ACM SIGPLAN International Symposium on SPLASH-E\",\"volume\":\"5 1\",\"pages\":\"0\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2021-10-17\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"1\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Proceedings of the 2021 ACM SIGPLAN International Symposium on SPLASH-E\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.1145/3484272.3484965\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 2021 ACM SIGPLAN International Symposium on SPLASH-E","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3484272.3484965","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 1

摘要

在本文中,我们探索了一种新的教学框架,即李斯科夫替代原理(LSP)的教学和教学方法。除了教授规则本身的细节之外,或者甚至可以代替教授规则本身的细节,我们提倡教授规则的操作化版本:子类型必须通过其父类型对其每个覆盖方法的黑盒测试。我们利用了这样一个事实,即黑盒测试应该被编写来捕获与规范的一致性,而不需要过度拟合或检查实现的内部细节(就像玻璃盒测试检查的那样)。违反可替换性规则的类型也将无法通过潜在的对应的超类型黑盒测试。此外,我们认为经典LSP后条件规则的过于严格的性质(在随后的工作中得到了改进)可能会成为教师和学生第一次学习这个关键概念的混乱来源。令人高兴的是,当通过黑盒测试考虑可替代性时,这个微妙但重要的概念的许多技术微妙之处自然消失了。我们提出,这种以测试为导向的教学可替代性方法是传统意义上的LSP检查的一种有价值的替代方法,其好处是学生可以直观地访问。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
Reframing the Liskov substitution principle through the lens of testing
In this essay, we explore a new pedagogical framing ofway of pedagogically and teaching the Liskov Substitution Principle (LSP). In addition to, or perhaps even in place of, teaching the specifics of the rule itself, we advocatepropose teaching an operationalised version of the rule: that a subtype must pass its supertype’s black box tests for each of its overriding methods. We leverage the fact that black box tests should be written to capture conformance to a specification without overfitting or checking implementation internalsdetails (as would be checked by glass box tests). A type that violates the rules of substitutability will also fail a potential corresponding black box test for the supertype. Additionally, we argue that the over-strict nature of the classical LSP Postcondition Rule (which has been improved in subsequent work) can be a source of confusion for both instructors and for students learning this crucial concept for the first time. Pleasingly, many of the technical subtleties of this nuanced but important concept drop out naturally when thinking of substitutability via black box tests. Thus we put forward We propose that this test-oriented means of teaching substitutability is a valuable alternative to the classical sense of checking the LSP, with the benefit of being intuitively accessible to students.
求助全文
通过发布文献求助,成功后即可免费获取论文全文。 去求助
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信