programmers.
A key feature of the model is that it is detailed
enough to explain the semantics of the language at
statement level and abstract enough to enable think-
ing about the program at the level of objects. The dis-
tinction as well as the connection between dynamic
execution in objects and static class code is made ex-
plicit. The emphasis is on stepwise modeling the dy-
namics of OO execution, i.e., the objects. Class code
is merely present beside the visualization – model and
tool indicate when and how the class code is involved
in supplying information for the execution.
Another important feature is that execution of a
program on the Java Virtual Machine (JVM) drives
the visualization. This provides a close and direct
connection to the actual execution of the language,
enforcing the semantics to be realistic as well as fa-
cilitating extensions to the model and tool.
In this paper we give an overview of the model
and tool; more detail can be found in (Luijten, 2003)
and (Vandalon, 2010).
There are several approaches related to ours: Je-
liot (Levy et al., 2002), Greenfoot (K
¨
olling, 2010),
BlueJ (K
¨
olling et al., 2003), and JIVE (Gestwicki and
Jayaraman, 2004; Lessa et al., 2010; Lessa and Ja-
yaraman, 2012). Jeliot is more low-level than Cof-
feeDregs, for example showing in detail how expres-
sions are evaluated. This makes Jeliot very well
suited to the initial stages of programming educa-
tion while CoffeeDregs also seeks to support more
advanced concepts. Greenfoot and BlueJ enable to,
visually, interact with instances of classes, but do not
aim for modeling the detailed execution of a program
– Greenfoot is especially well-suited for an informal
explorative introduction. JIVE is most closely com-
parable to our approach. Also JIVE is much more
ambitious in scope and application than CoffeeDregs:
it is a dynamic analysis tool that aims to provide de-
bugging facilities as well as being usable as a teach-
ing tool. The lightweight approach in CoffeeDregs
that restricts itself to “visualizing what happens in-
side the computer”, extended to complex concepts
like user interaction through the Graphical User In-
terface. JIVE offers different, integrated views, for
example using sequence diagrams to capture interac-
tions over a longer time period. A technical differ-
ence is that JIVE is integrated with the IDE Eclipse,
whereas CoffeeDregs is more IDE-independent. Also
the use of Visual Operational Semantics ((Jayaraman
and Baltus, 1996)) and the Contour Model ((Johnston,
1971)) is subtly different. For a more detailed com-
parison and full treatment of the more subtle differ-
ences, see (Luijten, 2003).
We introduce our approach in section 2. In the
next two sections we argue how to visualize, and what
to show or hide. In section 5 we introduce the tool as
applied to single threaded programs. In section 6 we
briefly discuss its implementation. In section 7 we
explain the extension to multi-threading. We consider
options to treat user interaction through the GUI in
section 8. This also provides an opportunity to explain
our didactic approach in some more depth and shows
the power of directly using information from the JVM
for visualization.
2 DIDACTIC APPROACH
We use the bottom-up approach in teaching OO pro-
gramming rather than the objects-first approach. One
rationale is that we want to introduce the activity of
a computer as performing small steps, for which it
can be easily understood that they can be mechanized.
Another reason is that, as our experience shows, it is
advantageous to introduce objects not as given black
boxes, but as composite entities explained in terms
of already understood basic concepts. What we show
initially is very simple: one class, one method, with
basic statements. Then we incrementally add method
decomposition and the OO concepts: object struc-
tures (references between objects, interaction through
method calls), class structures (inheritance), library
use, multi-threading, GUI programming, etc. The
model shows progressively more of these concepts.
In our teaching we use lecture notes (we are aim-
ing for a book version) with small chapters, introduc-
ing one concept at a time, providing its semantics in
terms of the, visualized, execution model. This se-
mantics presents an abstract view of what happens in-
side the computer, e.g., variables and objects are visu-
alized, stack frames are not. Thus we neither rely on
machine notions for modeling nor do we make use of
metaphor.
With each concept we provide a small example,
the execution of which is visualized by the tool. The
students then program more examples themselves, vi-
sualizing the execution with CoffeeDregs. Explain-
ing the concepts in terms of the model together with
a dynamic visualization proves effective in establish-
ing a clear, concrete domain to think and communi-
cate about programs. Note that with new concepts,
new features are added to the model or already present
ones are used in new ways, but that there is no change
in the level of abstraction – only one model is built up
incrementally.
CoffeeDregs can be used stand-alone, but also as a
plug-in to an IDE - we use the latter version for teach-
ing, incorporated as a plug-in to NetBeans.
CSEDU2012-4thInternationalConferenceonComputerSupportedEducation
66