The concept of class invariant in object-oriented programming

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Meyer, Bertrand, Arkadova, Alisa, Kogtenkov, Alexander
Natura: Preprint
Pubblicazione: 2021
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866913201103306752
author Meyer, Bertrand
Arkadova, Alisa
Kogtenkov, Alexander
author_facet Meyer, Bertrand
Arkadova, Alisa
Kogtenkov, Alexander
contents Class invariants -- consistency constraints preserved by every operation on objects of a given type -- are fundamental to building, understanding and verifying object-oriented programs. For verification, however, they raise difficulties, which have not yet received a generally accepted solution. The present work introduces a proof rule meant to address these issues and allow verification tools to benefit from invariants. It clarifies the notion of invariant and identifies the three associated problems: callbacks, furtive access and reference leak. As an example, the 2016 Ethereum DAO bug, in which $50 million were stolen, resulted from a callback invalidating an invariant. The discussion starts with a simplified model of computation and an associated proof rule, demonstrating its soundness. It then removes one by one the three simplifying assumptions, each removal raising one of the three issues, and leading to a corresponding adaptation to the proof rule. The final version of the rule can tackle tricky examples, including "challenge problems" listed in the literature.
format Preprint
id arxiv_https___arxiv_org_abs_2109_06557
institution arXiv
publishDate 2021
record_format arxiv
spellingShingle The concept of class invariant in object-oriented programming
Meyer, Bertrand
Arkadova, Alisa
Kogtenkov, Alexander
Programming Languages
Software Engineering
D.2.4; F.3.1; D.1.5; D.3.3; F.3.3
Class invariants -- consistency constraints preserved by every operation on objects of a given type -- are fundamental to building, understanding and verifying object-oriented programs. For verification, however, they raise difficulties, which have not yet received a generally accepted solution. The present work introduces a proof rule meant to address these issues and allow verification tools to benefit from invariants. It clarifies the notion of invariant and identifies the three associated problems: callbacks, furtive access and reference leak. As an example, the 2016 Ethereum DAO bug, in which $50 million were stolen, resulted from a callback invalidating an invariant. The discussion starts with a simplified model of computation and an associated proof rule, demonstrating its soundness. It then removes one by one the three simplifying assumptions, each removal raising one of the three issues, and leading to a corresponding adaptation to the proof rule. The final version of the rule can tackle tricky examples, including "challenge problems" listed in the literature.
title The concept of class invariant in object-oriented programming
topic Programming Languages
Software Engineering
D.2.4; F.3.1; D.1.5; D.3.3; F.3.3
url https://arxiv.org/abs/2109.06557