A Simple Semantics for Traversals in Object
Graphs
Karl Lieberherr and Mitchell Wand
College of Computer Science
Northeastern University
360 Huntington Avenue, 161CN
Boston, MA 02115, USA
[email protected], [email protected]
http://www.ccs.neu.edu/home/ lieber, wand
December 28, 2001
Abstract
Traversal through object graphs is needed for many programming tasks. We show
how this task may be specified declaratively at a high level of abstraction, and
we give a simple and intuitive semantics for such specifications. The algorithm is
implemented in a Java library called DJ.
1
Introduction
A common task in objectoriented programming is to take an object
o
in an object
graph and find all the objects
o
that are reachable from
o
according to some search
criterion. For example, given an object
o
of class
, find all the objects of class
that are reachable from
o
along a path that goes through some object of class
. In order to make the search tractable, we typically search based on
local meta
information
. In such a search, we search only those edges from
o
that
might
lead to
an object that satisfies the search criterion, based on the class structure of the object
graph. We may explore objects that are not on the path to a desired target object, but
that is an unavoidable consequence of searching based only on metainformation.
Work supported by the National Science Foundation under grants CCR9804115 and CCR
0097740 and by ARPA and BBN under agreement F3361500C1694.
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
In this paper we present a simple semantics for such a search, and introduce an
algorithm for performing the search, given a search criterion like the one above.
The semantics and algorithm address two technical problems: the meaning of the
modal operator “might”, and the treatment of inheritance. We give an example of
this algorithm as embodied in the DJ library for Java [3].
Section 2 presents our notation, and section 3 presents our model of classes
and objects. In section 4, we formulate the basic traversal problem in the terms
of our model.
The key to the problem is to find a set FIRST
c c
such that
e
FIRST
c c
iff it is possible for an object of class
c
to reach an object of type
c
by a path beginning with an edge
e
. Section 5 gives semantics to the core traversal
specifications of DJ and shows how to interpret them as search algorithms. Sec
tion 6 completes the story by showing how to compute the FIRST sets statically.
Section 7 presents an example showing how these concepts are employed in the
DJ library.
Section 8 discusses related work.
Finally, section 9 presents some
conclusions and ideas for further development.
2
Notation
We will be using relations as our fundamental tool, so we will need some notation
for dealing with relations.
If
A
and
B
are sets, a relation from
A
to
B
is a subset
R
of
A
B
. If
a b
R
, we
will write
R a b
,
a R b
, and
a b
R
interchangebly. A relation from
A
to
A
is
often called a relation
on A
.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '09
 ObjectOriented Programming, Locomotives of New Zealand, object graph

Click to edit the document details