Reframing the Liskov Substitution Principle through the Lens of Testing
In this essay we explore a new pedagogical framing of the LiskovSubstitution Principle (LSP). In addition to, or perhaps even in place of, teaching the specifics of the rule itself, we advocate an operationalised version of the rule: that a subtype must pass its supertype’sblack 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 im-plementation internals (as would be checked by glassbox tests). We show that a type that violates the rules of substitutability, will also fail the corresponding black box tests 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 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.
Wed 20 OctDisplayed time zone: Central Time (US & Canada) change
10:50 - 12:10 | |||
10:50 10mTalk | Chairs' Welcome SPLASH-E | ||
11:00 15mTalk | Teaching DevOps: A Tale of Two Universities SPLASH-E Richard Hobeck TU Berlin, Ingo Weber TU Berlin, Len Bass Carnegie Mellon University, Hasan Yasar Carnegie Mellon University DOI | ||
11:15 15mTalk | Ruggedizing CS1 Robotics: Tools and Approaches for Online Teaching SPLASH-E Boyd Anderson National University of Singapore, Martin Henz National University of Singapore, Hao-Wei Tee National University of Singapore DOI | ||
11:30 15mTalk | “You Have Said Too Much”: Java-Like Verbosity Anti-patterns in Python Codebases SPLASH-E DOI | ||
11:45 20mTalk | Reframing the Liskov Substitution Principle through the Lens of Testing SPLASH-E DOI |