Traversals of object structures: Specification and efficient implementation

Karl Lieberherr*, Boaz Patt-Shamir, Doug Orleans

*Corresponding author for this work

Research output: Contribution to journalArticlepeer-review


Separation of concerns and loose coupling of concerns are important issues in software engineering. In this paper we show how to separate traversal-related concerns from other concerns, how to loosely couple traversal-related concerns to the structural concern, and how to efficiently implement traversal-related concerns. The stress is on the detailed description of our algorithms and the traversal specifications they operate on. Traversal of object structures is a ubiquitous routine in most types of information processing. Ad hoc implementations of traversals lead to scattered and tangled code and in this paper we present a new approach, called traversal strategies, to succinctly modularize traversals. In our approach traversals are defined using a high-level directed graph description, which is compiled into a dynamic road map to assist run-time traversals. The complexity of the compilation algorithm is polynomial in the size of the traversal strategy graph and the class of graph of the given application. Prototypes of the system have been developed and are being successfully used to implement traversals for Java and Aspect J [Kiczales et al. 2001] and for generating adapters for software components. Our previous approach, called traversal specifications [Lieberherr 1992; Palsberg et al. 1995], was less general and less succinct, and its compilation algorithm was of exponential complexity in some cases. In an additional result we show that this bad behavior is inherent to the static traversal code generated by previous implementations, where traversals are carried out by invoking methods without parameters.

Original languageEnglish
Pages (from-to)370-412
Number of pages43
JournalACM Transactions on Programming Languages and Systems
Issue number2
StatePublished - Mar 2004


  • Adaptive programming
  • Aspect-oriented programming
  • Class graphs
  • Low of demeter
  • Object graphs
  • Strategy graphs
  • Structure-shy software


Dive into the research topics of 'Traversals of object structures: Specification and efficient implementation'. Together they form a unique fingerprint.

Cite this