Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to main content

Teaching Design by Contract Using Snap!

  • Chapter
  • First Online:
The Logic of Software. A Tasting Menu of Formal Methods

Abstract

With the progress in deductive program verification research, new tools and techniques have become available to support design-by-contract reasoning about non-trivial programs written in widely-used programming languages. However, deductive program verification remains an activity for experts, with ample experience in programming, specification and verification. We would like to change this situation, by developing program verification techniques that are available to a larger audience. In this paper, we present how we developed program verification support for Snap!. Snap! is a visual programming language, aiming in particular at high school students. We added specification language constructs in a similar visual style, designed to make the intended semantics clear from the look and feel of the specification constructs. We provide support both for static and dynamic verification of Snap! programs. Special attention is given to the error messaging, to also make this as intuitive as possible. Finally, we outline how program verification in Snap! could be introduced to high school students in a classroom situation.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    http://ddi-mod.uni-goettingen.de/ComputerScienceWithSnap.pdf.

  2. 2.

    Thanks Flor for the drawings!.

  3. 3.

    https://github.com/boogie-org/boogie.

References

  1. Aivaloglou, E., Hermans, F.: How kids code and how we know: an exploratory study on the Scratch repository. In: Proceedings of the 2016 ACM Conference on International Computing Education Research, pp. 53–61 (2016)

    Google Scholar 

  2. Barnett, M., Chang, B.-Y.E., DeLine, R., Jacobs, B., Leino, K.R.M.: Boogie: a modular reusable verifier for object-oriented programs. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2005. LNCS, vol. 4111, pp. 364–387. Springer, Heidelberg (2006). https://doi.org/10.1007/11804192_17

    Chapter  Google Scholar 

  3. Barnett, M., Leino, K.R.M., Schulte, W.: The spec# programming system: an overview. In: Barthe, G., Burdy, L., Huisman, M., Lanet, J.-L., Muntean, T. (eds.) CASSIS 2004. LNCS, vol. 3362, pp. 49–69. Springer, Heidelberg (2005). https://doi.org/10.1007/978-3-540-30569-9_3

    Chapter  Google Scholar 

  4. The Beauty and Joy of Computing. An AP CS Principles Course. https://bjc.edc.org/, Accessed Feb 2022

  5. Bohrer, B., Platzer, A.: Structured proofs for adversarial cyber-physical systems. ACM Trans. Embed. Comput. Syst. 20(5s), 93:1–93:26 (2021)

    Google Scholar 

  6. The Creative Computing Curriculum. http://creativecomputing.gse.harvard.edu/guide/, Accessed Feb 2022

  7. Cervesato, I., Cortina, T.J., Pfenning, F., Razak, S.: An approach to teaching to write safe and correct imperative programs – even in C (2019). https://www.cs.cmu.edu/~fp/papers/pic19.pdf

  8. Cheon, Y.: A Runtime Assertion Checker for the Java Modeling Language. PhD thesis, Department of Computer Science, Iowa State University, Ames. Technical Report 03–09 (2003)

    Google Scholar 

  9. de Gouw, S., Rot, J., de Boer, F.S., Bubel, R., Hähnle, R.: OpenJDK’s Java.utils.Collection.sort() is broken: the good, the bad and the worst case. In: Kroening, D., Păsăreanu, C.S. (eds.) CAV 2015. LNCS, vol. 9206, pp. 273–289. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-21690-4_16

    Chapter  Google Scholar 

  10. Dijkstra, E.: A Discipline of Programming. Prentice-Hall, Upper saddle River (1976)

    MATH  Google Scholar 

  11. Factorovich, P., Sawady, F.: Actividades para aprender a Program. AR: Segundo ciclo de la educación primaria y primero de la secundaria. Miller Ed Buenos Aires (2015)

    Google Scholar 

  12. Garcia, D., Harvey, B., Barnes, T.: The beauty and joy of computing. Inroads 6(4), 71–79 (2015)

    Article  Google Scholar 

  13. CS First. https://csfirst.withgoogle.com/s/en/home. Accessed Feb 2022

  14. Harvey, B., Mönig, J.: Snap! reference manual (2017). http://snap.berkeley.edu/SnapManual.pdf

  15. Hoare, C.: An axiomatic basis for computer programming. Commun. ACM 12(10), 576–580 (1969)

    Article  Google Scholar 

  16. Huisman, M., Monti, R.E.: Teaching design by contract using snap! In: 2021 Third International Workshop on Software Engineering Education for the Next Generation (SEENG), pp. 1–5. IEEE (2021)

    Google Scholar 

  17. Leavens, G.T., Baker, A.L., Ruby, C.: JML: a notation for detailed design. In: Kilov, H., Rumpe, B., Simmonds, I. (eds.) Behavioral Specifications of Businesses and Systems, pp. 175–188. Springer, Boston (1999). https://doi.org/10.1007/978-1-4615-5229-1_12

    Chapter  Google Scholar 

  18. Leavens, G.T., Cheon, Y., Clifton, C., Ruby, C., Cok, D.R.: How the design of JML accommodates both runtime assertion checking and formal verification. Sci. Comput. Program. 55(1–3), 185–208 (2005)

    Article  MathSciNet  Google Scholar 

  19. Leino, K.R.M.: Towards reliable modular programs. Technical report, California Institute of Technology (1995)

    Google Scholar 

  20. Meerbaum-Salant, O., Armoni, M., Ben-Ari, M.: Habits of programming in Scratch. In: Rößling, G., Naps, T.L., Spannagel, C. (eds.) Proceedings of the 16th Annual SIGCSE Conference on Innovation and Technology in Computer Science Education, ITiCSE 2011, Darmstadt, Germany, 27–29 June 2011, pp. 168–172. ACM (2011)

    Google Scholar 

  21. Meyer, B.: Eiffel: a language and environment for software engineering. J. Syst. Softw. 8(3), 199–246 (1988)

    Article  Google Scholar 

  22. Meyer, B.: Eiffel: The Language. Prentice-Hall, Upper Saddle River (1991)

    MATH  Google Scholar 

  23. Meyer, B.: Applying design by contract. Computer 25(10), 40–51 (1992)

    Article  Google Scholar 

  24. Oortwijn, W., Huisman, M., Joosten, S.J.C., van de Pol, J.: Automated verification of parallel nested DFS. In: TACAS 2020. LNCS, vol. 12078, pp. 247–265. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-45190-5_14

    Chapter  Google Scholar 

  25. An Introduction to Programming. A Pencil Code Teacher’s Manual. https://manual.pencilcode.net/, Accessed Feb 2022

  26. Pfenning, F., Cortina, T.J., Lovas, W.: Teaching imperative programming with contracts at the freshmen level (2011). https://www.cs.cmu.edu/~fp/papers/pic11.pdf

  27. Resnick, M., et al.: Scratch: programming for all. Commun. ACM 52(11), 60–67 (2009)

    Article  Google Scholar 

  28. Safari, M., Oortwijn, W., Joosten, S., Huisman, M.: Formal verification of parallel prefix sum. In: Lee, R., Jha, S., Mavridou, A., Giannakopoulou, D. (eds.) NFM 2020. LNCS, vol. 12229, pp. 170–186. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-55754-6_10

    Chapter  Google Scholar 

  29. Türk, T.: Local reasoning about while-loops. In: Joshi, R., Margaria, T., Müller, P., Naumann, D., Yang, H. (eds.) VSTTE 2010. Workshop Proceedings, pp. 29–39. ETH Zürich (2010)

    Google Scholar 

  30. Snap! extension for runtime assertion checking and static verification. https://gitlab.utwente.nl/m7666839/verifiedsnap/. Accessed Feb 2022

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Raúl E. Monti .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2022 Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Huisman, M., Monti, R.E. (2022). Teaching Design by Contract Using Snap!. In: Ahrendt, W., Beckert, B., Bubel, R., Johnsen, E.B. (eds) The Logic of Software. A Tasting Menu of Formal Methods. Lecture Notes in Computer Science, vol 13360. Springer, Cham. https://doi.org/10.1007/978-3-031-08166-8_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-08166-8_12

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-08165-1

  • Online ISBN: 978-3-031-08166-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics