Dynamic contract layers

Design by Contract (DBC) is a programming technique to separate contract enforcement from application code. DBC provides information about the applicability of methods and helps to narrow down the search space in case of a software failure. However, most DBC implementations suffer from inflexibility: Contract enforcement can only be activated or deactivated at compile-time or start-up, contracts are checked globally and cannot be restricted in their scope such as to the current thread of execution, and contracts cannot be grouped according to the concerns they relate to. In this paper, we present dynamic contract layers (DCL) for fine-grained and flexible contract management. Based on ideas from context-oriented programming, we extend DBC by a grouping mechanism for contracts, thread-local activation and deactivation of such groups, and selective contract enforcement at run-time. PyDCL, our proof-of-concept implementation of DCL, is built onto ContextPy, our COP extension for the Python programming language. We evaluate our approach by applying PyDCL contracts to the Moin-Moin Wiki framework.

[1]  R. Kramer iContract - The Java(tm) Design by Contract(tm) Tool , 1998 .

[2]  John L. Bruno,et al.  jContractor: A Reflective Java Library to Support Design by Contract , 1999, Reflection.

[3]  Guido van Rossum,et al.  The Python language reference manual: for Python version 3.2 , 2011 .

[4]  Andry Rakotonirainy,et al.  Context-oriented programming , 2003, MobiDe '03.

[5]  Bertrand Meyer,et al.  Applying 'design by contract' , 1992, Computer.

[6]  Hidehiko Masuhara,et al.  Improving the development of context-dependent Java applications with ContextJ , 2009, COP@ECOOP.

[7]  Mira Mezini,et al.  An Overview of CaesarJ , 2006, LNCS Trans. Aspect Oriented Softw. Dev..

[8]  Michael Haupt,et al.  An Introduction to Context-Oriented Programming with ContextS , 2007, GTTSE.

[9]  Reinhold Plösch Design by Contract for Python , 1997, APSEC.

[10]  Robert Hirschfeld,et al.  AspectS - Aspect-Oriented Programming with Squeak , 2002, NetObjectDays.

[11]  Robert Hirschfeld,et al.  Language constructs for context-oriented programming: an overview of ContextL , 2005, DLS '05.

[12]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[13]  Andrew Duncan,et al.  Adding Contracts to Java with Handshake , 1998 .

[14]  Gregor Kiczales,et al.  Aspect-oriented programming , 2001, ESEC/FSE-9.

[15]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[16]  Daniel Stearns,et al.  An Experience With Design by Contract , 2006, 2006 13th Asia Pacific Software Engineering Conference (APSEC'06).

[17]  Oscar Nierstrasz,et al.  Context-oriented programming: beyond layers , 2007, ICDL '07.

[18]  Andreas Zeller,et al.  Why Programs Fail: A Guide to Systematic Debugging , 2005 .

[19]  Bertrand Meyer,et al.  Eiffel: The Language , 1991 .

[20]  David Lorge Parnas,et al.  A technique for software module specification with examples , 1972, CACM.

[21]  Orla Greevy,et al.  Enriching Reverse Engineering with Feature Analysis , 2007 .

[22]  Cristina V. Lopes,et al.  Aspect-oriented programming , 1999, ECOOP Workshops.

[23]  Jean-Marc Jézéquel,et al.  Design by Contract: The Lessons of Ariane , 1997, Computer.

[24]  MeyerBertrand,et al.  Design by Contract , 1997 .

[25]  Dean Wampler,et al.  Contract4J for Design by Contract in Java: Design Pattern-Like Protocols and Aspect Interfaces , 2006 .

[26]  Fred L. Drake,et al.  The Python Language Reference Manual , 1999 .

[27]  Michael Haupt,et al.  A comparison of context-oriented programming languages , 2009, COP@ECOOP.

[28]  Rainer Koschke,et al.  Locating Features in Source Code , 2003, IEEE Trans. Software Eng..

[29]  Pedro Guerreiro Simple support for design by contract in C++ , 2001, Proceedings 39th International Conference and Exhibition on Technology of Object-Oriented Languages and Systems. TOOLS 39.