tion of the fault that caused a later observed failure.
and Online Python Tutor12 provide this
capability for Java and Python.
Examples and reuse. The activity of
programming has changed with the
availability of large repositories containing examples of shared code.
Programmers of all levels report finding and adapting examples as a core
6, 9 In response,
professional programming and end-user programming environments are
beginning to incorporate example support.
5, 31 Novices, too, want to learn via
examples, but may struggle to do so.
Blocks-based languages like Scratch
and Looking Glass use online sharing
and remixing programs to provide example access. But there is a trade-off
between the simplicity of reuse and
the robustness of reused code. For example, Scratch simplifies sharing of
code examples for novices by providing
a “backpack” for collecting program
snippets and assets that can be shared
and dragged into a new project. However, the backpack does not necessarily
guarantee the code will run correctly in
a new project.
In contrast, Looking Glass uses
a more complex process for reuse
in which users select the beginning
and end of behavior they want to use.
Coupled with execution history information, this can ensure the selected
code will function within the context
of a new program. A Play & Explore feature allows users to connect program
output to the line or lines of code that
caused it, helping users to understand
and begin to modify reused code.
Scaling Blocks Code
Why don’t professionals program with
block interfaces? One reason is that
direct manipulation has efficiency dis-
advantages when making small edits.
When creating an expression such as
(a/2 + b/2) in blocks, the programmer
must find and drag blocks for each of
the three arithmetic operators, and
then fill in holes with variables and
numbers. Similarly, when rearranging
an expression from (a/2 + b/2) to (a+b)/2,
the expression tree must be pulled apart
and put together again, requiring more
gestures and more forethought than
making the edits in text. HCI research-
ers observed that visual programming
languages can have a higher viscosity
than text code because they make small
changes more difficult.
Beyond viscosity, blocks environ-
ments can have several other usabil-
ity disadvantages compared to textual
˲Low density: Blocks take more
space on the screen than equivalent
˲ Search and navigation: It can be
challenging to find and navigate to the
relevant part of a blocks program in a
2D workspace, only part of which may
˲ Source control: collaboration and
version control systems are difficult to
use without a text representation.
The newest generation of blocks
programming tools includes features
designed to resolve the tension be-
tween usability advantages of text vs.
blocks. There are two approaches:
text-style entry and bidirectional mode
Text-style entry of blocks. Some new
blocks environments, such as Green-
foot’s frame-based Stride editor16 and
24 are designed to be used by pro-
grammers to create large programs,
so efficient editing is an important
Both Stride and GP improve efficiency by providing text-based editing
shortcuts within a blocks-oriented interface. To allow users to circumvent
the step of finding a block on the palette, these systems let programmers
enter blocks through an in-line autocomplete mechanism. Blocks can still
be chosen from a palette, but a knowledgeable programmer can insert them
by typing. The Stride editor also introduces a hybrid approach to editing
code, differentiating between low-level
and high-level structure (Figure 6). For
Figure 5. Block shapes show and enforce rules composition. Scratch commands compose
vertically, and expressions fit into holes. Here, a Boolean expression (diamond shape) is
being dropped into a matching hole for a loop test condition.
Figure 6. Greenfoot’s Stride editor combines text-style editing for expression-level details
with drag-and-drop blocks for higher-level program structure.