Title: Better Software Variability Through Better Abstraction of Traversals

Abstract

Invited Presentation for: http://prog.vub.ac.be/svpp08/

Traversal code is ubiquituous in software and it pollutes the real intent of the program with accidental details of the current structure in which the intent is expressed.

We present a novel model, called AP-F, for processing objects that supports improved software variability. The software variability is improved by using three approaches: (1) a novel separation of generic concerns (i.e., a novel, functional model for processing objects), (2) constraint-controlled automatic adaptation, and (3) manual, crosscutting adaptation using two aspect mechanisms (multi-methods and strategies). Regarding (1), object processing is broken down into three major concerns: ClassGraph, WhereToGo, WhatToDo. WhatToDo has three subconcerns: Down, Leaf, Up. WhereToGo uses a high-level traversal language a la Demeter, WhatToDo is functional-style advice on the traversal, inspired by, but different from a visitor. While a visitor uses the traditional Law of Demeter: "Talk only to your friends", WhatToDo uses the dual: "Listen only to your friends". WhatToDo creates a flow of information through the object separated into what information flows Down, is created at each Leaf and flows Up. Regarding (2), a type checker checks constraints that the multi-methods must satisfy and strategies are used to constrain possible class graphs. Regarding (3), multi-methods and strategies are used to adapt a generic computation in a powerful way. A small change to the program may have a broad effect cutting across the system to be built.

A system that supports software variability should have two properties: easy creation of class-graph-generic (or datatype-generic) programs and powerful adaptation and composition capabilities to specialize and compose the generic programs. AP-F has both and has advantages over other class-graph-generic programming approaches such as SYB (Scrap Your Boilerplate), Strategic Programming, Polytypic Programming and Generalized Fold. A key feature of AP-F is that it integrates smoothly high-level traversal control with the other desirable features leading to a superior way to abstract a large variety of traversals. This simplifies programs because traversal-related calls become all implicit.

Examples will be shown in two implementations of AP-F: A Java version, called DemeterF and a Scheme version, called apf-lib.