skip to main content
10.1145/3484272.3484965acmconferencesArticle/Chapter ViewAbstractPublication PagesConference Proceedingsacm-pubtype
research-article

Reframing the Liskov substitution principle through the lens of testing

Published: 17 October 2021 Publication History

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.

References

[1]
Elisa Baniassad. 2018. Making the Liskov Substitution Principle happy and sad. In Proceedings of the 40th International Conference on Software Engineering: Software Engineering Education and Training. 17–20.
[2]
Krishna Kishore Dhara and Gary T. Leavens. 1996. Forcing Behavioral Subtyping through Specification Inheritance. In Proceedings of the 18th International Conference on Software Engineering (ICSE ’96). IEEE Computer Society, USA. 258–267. isbn:0818672463
[3]
S. Drossopoulou, A. Francalanza, P. Müller, and A. J. Summers. 2008. A Unified Framework for Verification Techniques for Object Invariants. In ECOOP. Springer.
[4]
Gary T. Leavens, Erik Poll, Curtis Clifton, Yoonsik Cheon, Clyde Ruby, David Cok, Peter Müller, Joseph Kiniry, Patrice Chalin, and Daniel M. Zimmerman. 2008. JML reference manual.
[5]
Barbara Liskov and John Guttag. 2000. Program Development in Java: Abstraction, Specification, and Object-Oriented Design (1st ed.). Addison-Wesley Longman Publishing Co., Inc., USA. isbn:0201657686
[6]
Barbara H. Liskov and Jeannette M. Wing. 1994. A Behavioral Notion of Subtyping. ACM Trans. Program. Lang. Syst., 16, 6 (1994), Nov., 1811–1841. issn:0164-0925 https://doi.org/10.1145/197320.197383

Cited By

View all
  • (2022)Crossing Learning Thresholds Progressively via Active LearningProceedings of the 2022 ACM SIGPLAN International Symposium on SPLASH-E10.1145/3563767.3568128(14-23)Online publication date: 29-Nov-2022

Index Terms

  1. Reframing the Liskov substitution principle through the lens of testing

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    SPLASH-E 2021: Proceedings of the 2021 ACM SIGPLAN International Symposium on SPLASH-E
    October 2021
    96 pages
    ISBN:9781450390897
    DOI:10.1145/3484272
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 17 October 2021

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. CS-Education
    2. Substitutability
    3. Testing

    Qualifiers

    • Research-article

    Conference

    SPLASH '21
    Sponsor:
    SPLASH '21: Software for Humanity
    October 20, 2021
    IL, Chicago, USA

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)16
    • Downloads (Last 6 weeks)1
    Reflects downloads up to 01 Jan 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2022)Crossing Learning Thresholds Progressively via Active LearningProceedings of the 2022 ACM SIGPLAN International Symposium on SPLASH-E10.1145/3563767.3568128(14-23)Online publication date: 29-Nov-2022

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media