Structural abstraction: a mechanism for modular program construction

Much of programming languages research has been directed at developing abstraction mechanisms to support the “separation of concerns”: Orthogonal pieces of functionality should be developed separately; complex software can then be constructed through the composition of these pieces. The effectiveness of such mechanisms is derived from their support for modularity and reusability: The behavior of a piece of code should be reasoned about modularly—independently of the specific compositions it may participate in; the computation of a piece of code should allow specialization, so that it is reusable for different compositions. This dissertation introduces structural abstraction: a new abstraction mechanism that advances the state of the art in modularity and reusability by allowing the writing of highly reusable code—code whose structure can be specialized per composition, while maintaining a high level of support for modularity. Structural abstraction addresses the reliance of mainstream abstraction mechanisms on fixed structures. Although abstraction mechanisms have been developed to allow code to be reused over ranges of values (e.g., procedural abstraction) and ranges of types (e.g., type genericity), their modularity guarantees crucially rely on separately developed pieces of code having fixed structures: A procedure is a structure with a fixed name and a fixed number of argument types, a type-generic procedure is a similar structure with a fixed number of type variables. This rigid notion of abstraction means a piece of code cannot be reused for clients with different structures, and thus often leads to the same piece of functionality having to be manually specialized for the (possibly infinite number of) different structures it may be composed with. Structural abstraction addresses this limitation by providing a disciplined way for code to inspect the structure of its clients in composition, and declare its own structure accordingly. The hallmark feature of structural abstraction is that, despite its emphasis on generality and greater reusability, it still allows modular type checking: A piece of structurally abstract code can be type-checked independently of its uses in compositions. Thus, errors in generic code are detected before composition time—an invaluable feature for highly reusable components that will be statically composed by other programmers. This dissertation introduces two specific techniques supporting structural abstraction: static type conditions, and morphing. Static type conditions allow code to be conditionally declared based on subtyping constraints. A client of such a piece of code can configure a desirable set of features by composing the code with types whose positions in a subtyping structure satisfy the appropriate typing conditions. Morphing allows code to be iteratively declared, by statically reflecting over the structural members of code that it would be composed with. A morphing piece of code can mimic the structure of its clients in composition, or change its shape according to its clients in a pattern-based manner. Thus, using either static type conditions or morphing, the structure of a piece of code is not statically determined, but can be automatically specialized to reflect the structure of its clients in composition. We show how these structural abstraction techniques can be smoothly integrated with a modern Object-Oriented language, by implementing the languages cJ (for static type conditions) and MorphJ (for morphing), both of which are extensions of Java. We demonstrate the practical impact of structural abstraction by reimplementing a number of real world applications using cJ or MorphJ. We show that the reimplementations are more reusable, and, at the same time, modularly type-safe.

[1]  James R. Larus,et al.  Reflective program generation with patterns , 2006, GPCE '06.

[2]  Daniel G. Bobrow,et al.  Book review: The Art of the MetaObject Protocol By Gregor Kiczales, Jim des Rivieres, Daniel G. and Bobrow(MIT Press, 1991) , 1991, SGAR.

[3]  Maurice Herlihy,et al.  A flexible framework for implementing software transactional memory , 2006, OOPSLA '06.

[4]  Philip Wadler,et al.  Featherweight Java: a minimal core calculus for Java and GJ , 1999, OOPSLA '99.

[5]  Mirko Viroli,et al.  Variant parametric types: A flexible subtyping scheme for generics , 2006, ACM Trans. Program. Lang. Syst..

[6]  Stanley M. Sutton,et al.  Multi-Dimensional Separation of Concerns , 1999 .

[7]  Oscar Nierstrasz,et al.  Traits: A mechanism for fine-grained reuse , 2006, TOPL.

[8]  Sophia Drossopoulou,et al.  A Model for Java with Wildcards , 2008, ECOOP.

[9]  Gilad Bracha,et al.  Mirrors: design principles for meta-level facilities of object-oriented programming languages , 2004, OOPSLA.

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

[11]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

[12]  Sven Apel,et al.  Granularity in software product lines , 2008, 2008 ACM/IEEE 30th International Conference on Software Engineering.

[13]  Viktor Kuncak,et al.  Crosscutting techniques in program specification and analysis , 2005, AOSD '05.

[14]  Martin Odersky,et al.  Making the future safe for the past: adding genericity to the Java programming language , 1998, OOPSLA '98.

[15]  Andrei Alexandrescu,et al.  Modern C++ design: generic programming and design patterns applied , 2001 .

[16]  Michael D. Ernst,et al.  An Empirical Analysis of C Preprocessor Use , 2002, IEEE Trans. Software Eng..

[17]  Shan Shan Huang,et al.  Easy language extension with meta-aspectJ , 2006, ICSE.

[18]  Sven Apel,et al.  Type-Checking Software Product Lines - A Formal Approach , 2008, 2008 23rd IEEE/ACM International Conference on Automated Software Engineering.

[19]  Sven Apel,et al.  A Case Study Implementing Features Using AspectJ , 2007, 11th International Software Product Line Conference (SPLC 2007).

[20]  Shan Shan Huang,et al.  Morphing: Safely Shaping a Class in the Image of Others , 2007, ECOOP.

[21]  Yannis Smaragdakis,et al.  Static interfaces in C , 2000 .

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

[23]  William G. Griswold,et al.  Getting started with ASPECTJ , 2001, CACM.

[24]  Oscar Nierstrasz,et al.  Traits: Composable Units of Behaviour , 2002, ECOOP.

[25]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[26]  Markus Mohnen Interfaces with default implementations in Java , 2002, PPPJ/IRE.

[27]  E. Dijkstra On the Role of Scientific Thought , 1982 .

[28]  Jaakko Järvi,et al.  Associated types and constraint propagation for mainstream object-oriented generics , 2005, OOPSLA '05.

[29]  Eelco Visser,et al.  Program Transformation with Stratego/XT: Rules, Strategies, Tools, and Systems in Stratego/XT 0.9 , 2003, Domain-Specific Program Generation.

[30]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[31]  William R. Cook,et al.  Inheritance is not subtyping , 1989, POPL '90.

[32]  Stephanie Weirich,et al.  A Design for Type-Directed Programming in Java , 2005, WOOD.

[33]  Dachuan Yu,et al.  Variance and Generalized Constraints for C# Generics , 2006, ECOOP.

[34]  Simon L. Peyton Jones,et al.  Scrap your boilerplate: a practical design pattern for generic programming , 2003, TLDI '03.

[35]  Shan Shan Huang,et al.  cJ: enhancing java with safe type conditions , 2007, AOSD.

[36]  James Noble,et al.  Relationship aspects , 2006, AOSD.

[37]  Christopher G. Lasater,et al.  Design Patterns , 2008, Wiley Encyclopedia of Computer Science and Engineering.

[38]  Wilson C. Hsieh,et al.  Maya: multiple-dispatch syntax extension in Java , 2002, PLDI '02.

[39]  Lynn Andrea Stein Delegation is inheritance , 1987, OOPSLA 1987.

[40]  Howard I. Cannon Flavors : A non-hierarchical approach to object-oriented programming , 2007 .

[41]  Yannis Smaragdakis,et al.  Mixin layers: an object-oriented implementation technique for refinements and collaboration-based designs , 2002, TSEM.

[42]  Martin P. Robillard,et al.  Separating features in source code: an exploratory study , 2001, Proceedings of the 23rd International Conference on Software Engineering. ICSE 2001.

[43]  Ralf Lämmel,et al.  JavaGI : Generalized Interfaces for Java , 2007, ECOOP.

[44]  Don Batory,et al.  Scaling step-wise refinement , 2003, 25th International Conference on Software Engineering, 2003. Proceedings..

[45]  Torbjörn Ekman,et al.  The jastadd extensible java compiler , 2007, OOPSLA.

[46]  Walid Taha,et al.  Implementing Multi-stage Languages Using ASTs, Gensym, and Reflection , 2003, GPCE.

[47]  Peter H. Golde,et al.  C# Language Specification , 2003 .

[48]  D. L. Parnas,et al.  On the criteria to be used in decomposing systems into modules , 1972, Software Pioneers.

[49]  Henry Lieberman,et al.  Using prototypical objects to implement shared behavior in object-oriented systems , 1986, OOPLSA '86.

[50]  A B S T R Preventing Injection Attacks with Syntax Embeddings , .

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

[52]  V. Litvinov Constraint-based polymorphism in Cecil: towards a practical and static type system , 1998, OOPSLA Addendum.

[53]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[54]  Jeremy G. Siek,et al.  Concept Checking: Binding Parametric Polymorphism in C++ , 2000 .

[55]  Johan Jeuring,et al.  PolyP—a polytypic programming language extension , 1997, POPL '97.

[56]  Didier Rémy,et al.  Type checking records and variants in a natural extension of ML , 1989, POPL '89.

[57]  Simon Peyton Jones,et al.  Type classes: an exploration of the design space , 1997 .

[58]  Patrick Th. Eugster,et al.  Bridging Java and AspectJ through explicit join points , 2007, PPPJ.

[59]  Yannis Smaragdakis,et al.  JCrasher: an automatic robustness tester for Java , 2004, Softw. Pract. Exp..

[60]  Aaron Turon,et al.  Metaprogramming with Traits , 2007, ECOOP.

[61]  Stephen N. Zilles,et al.  Programming with abstract data types , 1974, SIGPLAN Symposium on Very High Level Languages.

[62]  Krzysztof Czarnecki,et al.  Synthesizing objects , 1999, Concurr. Pract. Exp..

[63]  William R. Cook,et al.  Mixin-based inheritance , 1990, OOPSLA/ECOOP '90.

[64]  Alessandro Orso,et al.  AMNESIA: analysis and monitoring for NEutralizing SQL-injection attacks , 2005, ASE.

[65]  Andrew Kennedy,et al.  Design and implementation of generics for the .NET Common language runtime , 2001, PLDI '01.

[66]  Dachuan Yu,et al.  Formalization of generics for the .NET common language runtime , 2004, POPL.

[67]  Mira Mezini,et al.  Conquering aspects with Caesar , 2003, AOSD '03.

[68]  Gilad Bracha,et al.  Adding wildcards to the Java programming language , 2004, SAC '04.

[69]  Antonio Cisternino,et al.  Reflection Support by Means of Template Metaprogramming , 2001, GCSE.

[70]  Xavier Leroy,et al.  A modular module system , 2000, J. Funct. Program..

[71]  Matthew J. Parkinson,et al.  The java module system: core design and semantic definition , 2007, OOPSLA.

[72]  Robert Cartwright,et al.  A first-class approach to genericity , 2003, OOPSLA '03.

[73]  Walid Taha,et al.  Multi-stage programming with explicit annotations , 1997 .

[74]  Craig Schaffert,et al.  CLU Reference Manual , 1984, Lecture Notes in Computer Science.

[75]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[76]  Andrew C. Myers,et al.  Parameterized types for Java , 1997, POPL '97.

[77]  Zhendong Su,et al.  The essence of command injection attacks in web applications , 2006, POPL '06.

[78]  Ralph E. Johnson,et al.  Analyzing multiple configurations of a C program , 2005, 21st IEEE International Conference on Software Maintenance (ICSM'05).

[79]  Ira R. Forman,et al.  Reflections on metaclass programming in SOM , 1994, OOPSLA '94.

[80]  Shan Shan Huang,et al.  Statically safe program generation with safegen , 2005, GPCE'05.

[81]  Jonathan Bachrach,et al.  The Java syntactic extender (JSE) , 2001, OOPSLA '01.

[82]  Robin Milner,et al.  Definition of standard ML , 1990 .

[83]  Niklaus Wirth,et al.  Programming in Modula-2 , 1985, Texts and Monographs in Computer Science.

[84]  Yannis Smaragdakis,et al.  Implementing Layered Designs with Mixin Layers , 1998, ECOOP.

[85]  Yannis Smaragdakis,et al.  JTS: tools for implementing domain-specific languages , 1998, Proceedings. Fifth International Conference on Software Reuse (Cat. No.98TB100203).

[86]  Dirk Draheim,et al.  A type system for reflective program generators , 2011, Sci. Comput. Program..