Smarter Cut-and-Paste For Programming Text Editors

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Smarter Cut-and-Pastefor Programming Text Editors

Glen Wallace, Robert Biddle and Ewan Tempero


School of Mathematical and Computing Sciences
Victoria University of Wellington
New Zealand
gwallace@ the .net.nz {R0bert.B iddle IEwan .Tempera}@mcs .vuw.ac .nz

Abstract the key concepts involved in these activities, to form the ba-
sis for higher-level support within a text editor. The main
The process of creating software involves many differ- work of the project was then to develop a prototype text ed-
ent tools, but the text editor is still one of the most impor- itor based on these concepts.
tant. Moreover, one of its basic facilities, cut-and-paste, still Our hope is that these efforts will lead to improved text
plays a critical role in enabling simple reuse. In this paper editors. Text editing is an important user interface element,
we explore how to improve cut-and-paste within text editors and editors are important because users spend significant
used for programming. We describe how programmers use time and effort working within theim, even in single ses-
cut-and-paste for reuse, and suggest the basic underlying sions. Understanding and improving text editors is there-
principles. We then report on a prototype tool we developed fore a worthwhile objective.
to explore a set of techniques to provide better support for Beyond editors, our aim is to bettlar understand how pro-
cut-and-paste. gramming languages and programs should support reusabil-
ity. Our previous work has included a conceptual model for
programming language support for ireuse [3]. Our original
1 Introduction intention in developing that model was to better understand
programminglanguage design. However, the design of pro-
Software development involves many different activities, gramming languages impacts the ways in which programs
and these activities have led to a variety of tools to support are constructed, and especially affects how parts of a pro-
them. One of the early tools is still widely used today: the gram are put together.
text editor. Text editors have a very general interface, and The rest of this paper is structured as follows. Section
provide primitive but general support for creating programs 2 describes some key ways in which programmers use the
in traditional textual programming languages. Our general primitive facilities of text editors to reuse and adapt code,
research interest is in code reuse, and text editors provide and identifies some underlying concepts that emerge. Sec-
support for reuse through mechanisms for textual cut-and- tion 3 describes Machete, our prototype tool that adds visu-
paste. This support is really very primitive, but it is heavily alisation to better support text editor cut-and-paste. We then
relied on by programmers to reuse old code and adapt it discuss our experience in section 4, and finally present our
to new circumstances. In this paper, we describe a project conclusions in section 5.
that explored how text editors might better support cut-and-
paste in order to better support code reuse.
2 Using Text-Editors to Cut-and-Paste Pro-
Programming is a complex task, and even the processes
involved when the programmer interacts with a text ed- grams
itor are quite complicated. In particular, programmers
work through text editors to explore and develop programs The basic ideas of cut-and-paste are now very
in a creative and dynamic way that does not follow pre- widespread, familiar, and reasonatdy consistent. Despite
determined plans. For these reasons, we choose to base our the common term “cut-and-paste”, ,there are typically three
exploration on an analysis of what programmers actually operations: cut, copy, and paste. The user may select a
do when using text editors. The first step in our exploration source region, and invokes either si cut or copy operation.
was to describe the ways in which programmers used cut- In both operations, the selected text is copied to a buffer;
and-paste to reuse and adapt code. We then tried to identify cut also deletes the text in the source region. The user may

56
$10.000 2001 IEEE
0-7695-0969-WO1
also indicate a destination location, and invoke ayaste oper- is taken from the documentation or tutorials. The im-
ation, which copies the text from the buffer to the indicated portant points to consider are:
location.
The first step of our study was to form an initial cata- - Which control structures are of interest and
logue of the ways in which cut and paste is used within which should be discarded.
text editors for writing programs. Our procedure was to fo- - Which variables form part of the control system
cus on one particular text-editor,on one particular program- in the code. Which variables should be replaced
ming language, and to gather information by observation by variables in the destination context, and which
of ourselves and other programmers. We used the Emacs variables are irrelevant and should be removed.
text editor [12], and the Java programming language [6]. - Which methods contribute to the control of the
All the programmers involved were experienced with these, structure, which methods contribute to the algo-
and we regard the usage of each as sufficiently typical of rithm being reused, and which methods are sim-
text editor usage and programming use of a text editor. In ply padding for the purpose of the example.
particular, although Emacs allows sophisticated and exten-
sive customisation, the usage of Emacs we considered did Our earlier work on code reuse developed a conceptual
not rely on this. model for the ways in which languages allow code compo-
We recorded interesting usage as “use cases”. A use case nents to be invoked at run time from different contexts [3].
is a description of a typical interaction in a system [7], and Many key issues concern dependencies between the compo-
the term is widely used in the field of object-oriented design nent and the contexts. For example, a context may depend
to attempt to describe the functionality a system should pro- on a component taking certain parameters, or a component
vide. We identified a number of use cases, and summarise may depend on the context setting the value of some global
them below as conceming principally blocks of code, vari- variable. In general, dependencies limit reusability, but we
ables, methods, or refactoring. It might seem that only the classified a variety of dependencies to better explain the ex-
first category, blocks of code. relates to cut-and-paste. How- act nature of their impact.
ever, we observed that the other categories are also related, In text editor cut-and-paste, dependencies also play a key
because cut-and-paste typically involves extensive brows- role. There are dependencies between a selected block of
ing and reviewing of code, and extensive modification and code and the surrounding text, and these may be affected
customisation. by any cut or paste. In the processes of reusing code by
cut-and-paste, the programmer must consider the dependen-
2.1 Manipulating Blocks cies, and address these where necessary. Much of this work
involves manipulating variable usage and method calls, as
Manipulation of blocks of code includes various kinds discussed below.
of code structure. We use the term fragments to refer to
program statements, lists of statements or blocks, being a 2.2 Manipulating Variables
number of statements enclosed in brackets. The term ea--
pression we use to refer to a valid expression including any The category involving manipulation of variables in-
language construct that can be evaluated to produce a value, cludes a number of use-cases, but we must remember that
such as arithmetic operations and method invocations. So, there is an area of overlap with the manipulation of meth-
the use cases include: ods, because of the object-oriented nature of the language:
where the variable refer to objects, they are used by invok-
Insert, remove, or reorder code fragments, and high-
ing their methods. The identified use-cases are summarised
light any changed dependencies between the fragment
below.
and the surrounding context.
Insert, remove, or replace expressions, and highlight 0 Display the variables in scope at the indicated point.
any inconsistencies or changed dependencies.
0 Display the variables that are referenced in a selection
Reusing code structures. but undeclared there.
This common and important kind of code reuse in- 0 Display the shadowed variables, which would be us-
volves copying a block of code, where whole block able but for others with the same name.
of code is not being reused, but rather the underlying
0 Display a variable’s type and origin.
structure of the code. Accordingly, the user then re-
places parts of the block with their own code as ap- 0 Display a variable’s places of usage.
propriate. This form of reuse is common when us- 0 Display all the methods and fields that are invoked for
ing library or framework code, where example code an object variable.

57
0 Determine the data flow through variables in the code: restructuring control flow statements.. Architectural level
which variables affect any given variable, and which can involve extractinga composition or inheritancerelation-
variables any given variable affects. ships, moving functionality within inheritance hierarchies,
b Change the name of a variable. and partitioning functionality differently within classes.
0 Introduce a new variable. Accomplishing refactoring simp1,y using a text editor
will typically involve sequence of low level cut, copy and
0 Remove an unused variable.
paste operations. However, the essence of the modification
b Remove all usage of a variable.
at a higher level is to change the structure of the code with-
0 Shift variables from local within a method, to a field: out changing the functionality at all. This means that these
or vice-versa. operations are quite constrained, and this allows specific
b Change the declaration attributes of a variable, and higher level support for refactoring. Because the modifica-
highlight introduced inconsistencies. tions involved in restructuring do allow tighter constraints
and better high-level support, we chose to focus initially on
2.3 Manipulating Method Calls the less constraineduse-cases discussed in the previous sec-
tions.
There are numerous ways method calls may be manipu-
lated, as shown below. While we are assuming use of Java, 2.5 Towards Better Support for Cut-and-Pastefor
an object-orientedlanguage, many of these cases would also Programs
apply to procedural languages as well.

Show the methods in scope, identifying: The first step in our project was to describe the use-cases
where cut-and-paste was used in programming. The prob-
- Inherited methods, and the relevant superclass. lem is that it is a very low level concept, and even good text
- Overriding methods, and the relevant super- editor support leaves the user with a high mental overhead
classes. of determining the implications of steps, and keeping track.
- Any interfaces the method takes part in imple- To conclude this step in our project, we analysed the user
menting. tasks involved in the use-cases, and tried to identify higher
- Static methods. level concepts to better support the user.
- Instance methods. It seemed that the majority of the use cases described
0 Show a method’s signature, including parameter and involved a relatively small number of concepts:
return types.
Displaying variable declarations and method defini-
0 Show variables and method return values that are used
tions.
as parameters to method invocations.
0 Show variables and method parameters that take values 0 Showing variable scoping, or visibility.
from method return values. Access control, determining whether access is permit-
0 Change the name of a method. ted.
0 Change the name of a method applied to a particular 0 The inheritancehierarchy.
object, or type of object. 0 Type inference and type compatibility checking.
b Remove all usage of a method. 0 Determining dependencies, seeing how a variable or
Modify the parameters of a method, and highlight method affects other code.
introduced inconsistencies, of changing their order, 0 Determination of where and how variables and meth-
adding parameters, removing parameters, or changing ods are used in the code. For variables, this involves ,
parameter types. the fields and methods referred to through each ob-
ject variable. For methods, this involves the parameter
2.4 Refactoring types, and retum type.

Refactoring is the term usually applied to make the code Implicit in many cases is the underlying idea of a naviga-
more maintainable or reusable through improvement to its tion around the code. We need to index the code in several
intemal structure [5]. Refactoring can involve either code ways, move from definitions to usages or back, and see de-
level changes or architectural changes that effect the global pendencies between elements.
structures and abstraction of the program. In the past, the recognition that programs follow highly
Code level changes can include reorganising expres- structured syntactic forms have been used to support the ar-
sions, moving common code to or from helper methods, and gument that code should not be treated as mere text [lo].

58
0
ctor inScopeDecl // we c a n o n l y e v e r h a v e o n e l o c a l variable w i t
// name, h e n c e we c a n s t o p l o o k i n g a f t e r t h e f i

Vector outScopeVars // n e s t e d c l a s s e s w i l l shadow f i e l d s o f t h e San


// (regardless o f type)
outScopeDeclAl1
// the below 11 n o t t h e b e s t a5 i t c a n n o t d e t e r
// < c l assnamez. t h i s . < f i e l d> method o f r e f e r e n c i
peReference scope // shadowed b y t e a n e s t e d C l a s 5

// f i n d t h e used v a r i a b l e s d e c l s t h a t a r e under
// selection

S i mpl e V a r i ab1 e ) i nScc


a local that local

Enumeration

f ( v a r . 1 sFi e l d I n h e r i ted()) {
outScopeDeclAl1 .addElement[new VariableDe

else if(lisLoca1) {
// t o l o o k f o r a f i e l d we m u s t n ' t have f c
// l o c a l b y t h e same name
VariableDecl fieldDec1 = s.getField(var.c
if(fieldDec1 I= null) {

Figure 1. The Machete interface provides a split view for navigation, the tree display on the left and
the code display on the right. (The pane widths have been reduced for this figure.) The tree view
shows definitions of names, organised according to the scopes of the names.

59
Construction tools that make use of this language knowl- complete fragments of code, that is groups of expressions
edge were termed “syntax-directed editors”. These tools and/or statements. While we want to restrict the selection,
failed to gain widespread user acceptance mainly due to the doing so by forcing the programmer to be careful would be
way in which they were perceived to restrict the way devel- counter-productive. This means we need a mechanism that
opment took place. In design to better support cut-and-paste allows a programmer to easily make allowable selections.
by using syntactic structure, we must be cautious to avoid This “guided” selection places restrictions on the kind of
constraining development in the same way syntax directed code that can be reused, and raises issues as to how allow-
editors were thought to do. able selections are indicated in the user interface.
There are a number of other editors that are aware of the As we have discussed above, the visualisation provided
semanatics of the language, such as PGS [I], Pan [ 2 ] ,or the by our tool had to make the dependencies clear. At the level
Desert editor [ 111. Their primary goal is to support the con- of reuse that we are interested in, dependencies are mainly
struction of code, whereas Machete’s main goal is provide indicated by definition and use of names, which is what our
feedback to the programmer on the consequences of ma- tool concentrates on. A common issue that a programmer
nipulating already formed code, although there are clearly must address in relation to a fragment of code under con-
strong relationships between the different kind of systems. sideration for reuse is to determine where a name in that
fragment is defined. In a standard text editor, answering
3 Machete: a Prototype Tool that question will typically involve traversing the file to find
the definition. There are two tasks being performed in such
action -navigation and identificatiaa - and both must be
In this section, we describe Machete, our prototype tool
for exploring support for code reuse. The main goal of supported. We chose to use a split view to support naviga-
our prototype was to exploit our analysis of the issues that tion, with one pane (the tree display) providing an indexing
structure on the code loaded into Machete, while the other
programmers face when using cut-and-paste. Our analysis
suggested that the main issue faced by programmers is un- pane (the code display) shows the actual code. We also
derstanding the consequences of their action. Specifically, make extensive use of colour and icons to support identi-
understanding the dependencies that source region has on fication. (See figure 1).
its context that would be affected by pasting it in the new
context. Accordingly, we were interested in a user inter- 3.2 Selection
face that provided a visualisation of the code fragment and
its context that would make it easy for the programmer to Having made the decision to restrict the fragments of
reach this understanding. code a programmer could select for copying, we had to then
provide a simple mechanism to allow the programmer to
3.1 Prototype Design easily make such a selection. The mechanism had to be
predictable in its behaviour, easy to use, and provide good
To meet our goal, our prototype did not actually have feedback. In particular, it had to be a clearly superior mech-
to provide editor support - in fact it did not even have to anism to use than the standard cut-and-paste mechanism of
support the cut operation. All that was really needed was to editors such as Emacs.
allow the user to select a fragment of code and to provide The mechanism we chose was to have the user indicate
information about that fragment of code. a start point and then expanding or contracting the selection
To provide the information of a selected fragment of about this point. The granularity of 1he change in selection
code, our prototype had to be able to analyse that fragment. is to increase (or decrease) to the next “enclosing” syntac-
Such analysis would require some level of parsing of the tically complete block. Thus the first selection will be of a
fragment. This raised the issue of what selection of code variable, which is then increased to include the expression
would be allowed. Text editor users are used to being able the variable is in, then the statement, then the block, and so
to select arbitrary pieces of text, but such selections could on (see figure 2). This is similar to hehaviour that has been
easily result in code fragments that were unparsable. Deal- available in some editors for several years, where a single
ing with such fragments is a similar problem to the problem click sets the starting point, a double click selects a “word”,
of compilers providing good error reporting for incorrect a triple click a “line”, and so on. Our selection mechanism
code[4], however this was not our interest. Furthermore, is smarter with respect to the syntax of the language.
our observation of programmers suggested that for the most The change in selection is achieved through the mouse.
part programmers who are selecting a piece of code with the If a selection exists, a left click within the selection will
intention of copying it to use somewhere else will typically cause it to expand to the next step. while a right click will
choose a segment that falls on natural syntactic boundaries. cause it to contract to the previou:, step. If there are no
Accordingly, we choose to restrict selection to syntactically remaining steps to expand or contract to, then the opera-

60
(a)
1ocalDecl
if(localDec1 I= null) {
- s.getLoca1 (var.getName(
(b)
if(localDec1 I= null)
IocalDecl = s . g e t L o c a 1 (var.getName(
<
// n o t e t h e i n scope f i e l d s and l o c a l s a r e // n o t e t h e i n s c o p e f i e l d s and l o c a l 5 a r e
/ / handled p p r o p r i a t e v i s i t methods // h a n d l e d e v i s i t methods
if(start > .getstart()) { if(start > 0) c
// i f i t e the selecnon record i t // i f i t ection record i t
outScopeDec1 .addEl ement(1 oca1 D e c l ) ; outScopeDec1 . a d d E l e m e n t ( l o c a l D e c l ) ;
outScopeDeclAl1.addElement(localDecl); outScopeDeclAl1 .addElement(localDecl) ;
1 1
isLocal = t r u e ; isLocal = true;
1 1
(c> (4
" 1ocalDecl = s . g e t L o c a 1 (var.getName( 1ocalDecl = 5 . g e t L o c a l (var.getName(
I= null) {
// n o t e t h e i n scope f i e l d s and l o c a l s a r e / / n o t e t h e i n s c o p e f i e l d s and l o c a l s a r e
// h a n d l e d i n t t h e a p p r o p r i a t e v i s i t methods
1 f(
// i fi t i s before the selection record i t
outScopeDec1 . a d d E l e m e n t ( l o c a l D e c l ) ; outScopeDec1 .addEl e m e n t ( l o c a l D e c 1 ) ;
outScopeDeclAl1 .addElement(localDecl); outScopeDeclAl1 .addElement(localDecl):
1 1
isLocal = true; isLocal = true;
1 1
1 E
(e) (f)
1sLocal = f a l s e ;
.hasPrefix()) {
/ / i f t h e v a r i a b l e use has a p r e f i x i t c a n o n l y
// r e f e r t o a f i e l d
I 'I 'j I O C a t U e C l = s.getLocal(var.getName( 1 ocalDecl = 5. g e t L o c a l ( v a r . getName(
i f ( l o c a l O e c 1 I = null) {
// n o t e t h e i n scope f i e l d s and l o c a l s a r e
/ I h a n d l e d i n t t h e a D D r o D r i a t e v i s i t methods
if(;tart > 'ocalDec1 . g e t S t a r t ( ) ) {
// t f i t i s before t h e s e l e c t i o n record i t
ouflcopeL3ec' .addEl emenrc? oca1 Oec' 1 ;
OII t 5 c o p e 3 e c l A l l .addEl cment( 1oc il Gec 1 ) ;
3
isLocal = true;
1
1.
i f ( v a r . 1 sFi e l d I n h e r i t e d ( ) ) { if (var.1 sFi e l d I n h e r i t e d ( ) ) {
o u t S c o p e D e c l A l 1 .addElement(new V a r i a b l e D e c l (var.gn outScopeDec1 A1 1 .addEl ementcnew V a r i ab1 eDecl ( v a r . g r
1 1

Figure 2. Code is selected by choosing a starting point and expanding the selection from that
point. This shows the sequence of expansions starting with the local variable 1ocalDecl. On
the initial selection (a), the definition of localDecl has been coloured (bold red). With each left
click, the selection expands to the next enclosing syntactic fragment, a method name (b), method
call with no arguments (c), if condition (d), if statement (e), and if statement block (f). As new
names are included in the selection, other parts of the code are coloured (for example the field
outScopeDeclAl1 is coloured in the if statement following the selected fragment in (e), and the
local variable isLoca1 is coloured in (f)). Figure 1 is the result after 2 more left clicks.

61
tion will do nothing. Clicking the centre button at anytime, In both the tree and code displays declarations and us-
or the left button in a region outside the current selection, ages of interesting variables are highlighted. The colour
will cause the selection to be cleared. This allows the pro- that the usage or declaration is highlighted indicates what it
grammer to quickly cycle through the allowable selections is and how it relates to the current selection. There are four
with little cognitive overhead. Notice that this mechanism cases for colouring:
provides no explicit information regarding what the next
selection would be in the expansion/contraction sequence, 0 Declarations of variables that are used within the se-
however, provided the implementation is quick enough, the lection, but declared outside are marked in bold red.
mechanism is simple enough to allow the programmer to 0 Usages outside the selection of variables used (but not
experiment until the desired selection is determined. declared) within the selection are marked with brick
The current selection is indicated using the traditional red.
mechanism of changing the colour of the background. We 0 Declarations that occur within thle selection are marked
considered more sophisticated feedback, such as different with bold blue.
fonts or graphical overlays, but decided to stay with what
0 Usages within the selection of variables declared
the programmer would be familiar with for this prototype.
within the selection are marked in purple.
3.3 Navigation For example, in figure 1, the declarationof the variable var
is coloured bold red, because it is used within the selection.
Navigation is provided by an indexing structure based on All uses of it outside the selection are coloured brick red.
the definition of names. This is a tree structure organised ac- The variable localDecl is coloured blue on its declara-
cording to the nesting of scopes, and with labelled intemal tion, and purple whenever it is used.
nodes corresponding to different collections of definitions The selection mechanism is tied to the tree display. As
and leaves corresponding to the definitions themselves. In the selection expands and contractsthe variable declarations
this way, the scope of definitions is clear. The tree nodes in the tree display and the variable declarations and uses in
can be expanded or collapsed by direct user control, but will the code display will be updated so that their highlighted
also be changed by the current selection (see below). state will reflect the dependencies between the currently
The programmer may click the left mouse button on a selected fragment and the surrounding context. The rele-
node in the tree display and this will result in the code dis- vant tree nodes will be expanded to show the definitions of
play scrolling to place the contents of that node in the centre the various names used within the slelection, including any
of the code display. This allows the user to quickly locate fields. The names so used will also be coloured in the tree
the declarations. Using the right mouse button will achieve display to make them easily identifiable. This means that
the same effect, but also the declaration in question will be all the definitions affected by the selection are immediately
selected, which will cause all the uses of that variable to be visible. The navigation mechanism can then be used to ex-
highlighted. plore the consequences of moving the selection to a new
context.
3.4 Identification
3.5 Implementation details
Different icons in the tree display are used to show the
different kinds of declarations, as shown in left pane of the Machete was implemented in Java. It uses JavaCC [8], a
user interface shown in figure 1. Groups of similar decla- Java compiler compiler, and JTB [9], a syntax tree builder,
rations (for example, fields, methods, method arguments) to parse the input file and construct an abstract syntax tree,
use a “container” icon, with the different groups indicated that is the basis for both the selection mechanism and the
by different colours. Declarations of variable-like names tree display. It uses the j ava . swing package for the basic
(such as fields, arguments, local variables) are shown with user interface components, and java.s w i n g . text for
right-slanted rectangles, again using colour to differentiate the text display and the selection mechanism.
each kind. Non variable-like names (such as method names)
use left-slanted rectangles. Class-like names use circular
icons, return values are shown by the backwards arrow, and 4 Discussion
blocks are shown by a horizontal rectangle. Blocks relating
to statements are specialised icons (for example, if and Text editor support for pr0gram:min.g is a large subject,
f o r statements). This approach can be further extended and this project was much more limited in scope. However,
to have the icons convey more information in the form of the prototype did allow us to explore a set of techniques
accessibility and variability information. designed to better support cut-and-paste.

62
We evaluated the prototype principally by using the ness, scale, and modularity that cut-and-paste can never
“cognitive walkthrough” technique [ 131. Normally, our have. However, there is still a place for cut-and-paste. It is
practice would be to then proceed to usability testing, but a low-level tool, but it is highly usable, highly versatile, and
the limited nature of the prototype would have made this often the most expedient way to reuse existing code. Cut-
difficult. Moreover, we had some difficulties with the Java and-paste is worth taking more seriously, and worth better
run-time performance, and our prototype was slower than is support.
necessary for normal use of a text editor.
Our study of the prototype did show that our design did References
appear to provide better support for the basic elements in-
volved in using cut-and-paste. Compared with an ordinary [I] R. Bahlke and G . Snelting. The PSG system: From for-
text editor. it was clear that the prototype significantly in- mal language definitions to interactive programming envi-
creased support for both navigation and detection of depen- ronments. ACM Transactions on Programming Languages
dencies. We found ourselves exploring code by using the and Systems, 8(4):547-576, Oct. 1986.
new features, using the tree navigation and guided selec- 121 R. A. Ballance, S. L. Graham, and M. L. V. D. Vanter. The
tion, and assessing the highlighted information identified in PAN language-based editing system. ACM Transactions of
the code. This suggests that this form of support fosters ac- Softwaia Engineering and Methodology, 1(1 ):95-127, Jan.
tive exploration and reflection, which is useful just for code 1992.
understanding, without the reuse focus. In some way the [3] R. Biddle and E. Tempero. Understanding the impact of lan-
guage features on reusability. In M. Sitaraman, editor, Pro-
features made the prototype seem faster that we were used
ceedings of the Fourth Intel-national Coiq5erence on Software
to, despite the overall slowness of our prototype implemen-
Reuse. IEEE Computer Society Press, Apr. 1996.
tation. In particular, the guided selection worked well, and (41 G. V. Cormack. An LR substring parser for noncorrect-
we found that as well as using to select blocks, we also used ing syntax error recovery. In B. Knobe, editor, Proceed-
it to identify and explore the structure of the code, while ings of the SIGPLAN ’89 Conference on Programming Lan-
also being able to rapidly review identified details. guage Design und Implenientation (SIGPLAN ’8Y), pages
Guided selection, declaration and structure navigation, 161-169, Portland,OR, USA, June 1989. ACM Press.
and code identification and highlighting all seem basically [5] M. Fowler. Refactoi-ing: Improving the Design of Existing
sound user interface techniques. Overall, we think this is Code. Addison-Wesley,Reading, USA, June 1999.
evidence that text editors can provide better support for cut- [6] J. Gosling, B. Joy, and G. L. Steele. The Java Language
Specification. Addison-Wesley,Reading, USA, 1996.
and-paste, by using available syntactic structure, but with- [7] I. Jacobson, M. Christerson, P. Jonsson, and G. Overgaard.
out going all the way to the restrictions of syntax-directed Object-Oriented Software Engineering: A use case driven
editing. In fact, it seemed that a little went a long way. Even approach. Addison-Wesley, 1992.
small improvements beyond the typically primitive text ed- [SI Homepage for JavaCC, Sun Microsystems, Inc.
itor capabilities might might make code reuse significantly http://www.suntest.com/JavaCC/.
easier. Future work will need to explore more full support [Y] Homepage for JTB, Department of Com-
for smarter cut-and-paste in a working text editor. puter Science, University of Purdue.
http://www.cs.purdue.edu/jtb/.
[IO] A. A. Khwaja and J. E. Urban. Syntax-directed editing
5 Conclusion environments: Issues and features. In E. Deaton, K. M.
George, H. Berghel, and G. Hedrick, editors, Pmceedings of
This paper. has reported on our exploration of smarter the ACMISIGAPP Symposium on Applied Computing, pages
cut-and-paste in text editors used for programming. We be- 230-237, Indianapolis,IN, Feb. 1993. ACM Press.
[ 111 S. P. Reiss. The Desert environment. ACM Transactions
gan by describing the ways in which programmers use cut-
on Softwai-e Engineering and Methodology, 8(4):297- 342,
and-paste, and by identifying the key underlying concepts.
Oct. 1999.
We then used this analysis to drive the design of a proto- 1121 R. Stallman. GNU Emacs manual. Free Software Foun-
type tool to provide better cut-and-paste support. The tool dation, Cambridge, USA, 13th, Emacs version 20.3 edition,
was limited in scope, but appeared to show the ideas had July 1997.
merit. It does seem possible to better support cut-and-paste [I31 C. Wharton, J. Rieman, C. Lewis, and P. Polson. The
through guided selection, navigation by declarative struc- cognitive walkthrough method: A practitioner’s guide. In
ture, and by highlighting identified details within the code. J. Nielsen and R. L. Mack, editors, Usability Inspection
Cut-and-paste is a primitive interface capability, but Methods, chapter 5, pages 105-140. Wiley, 1994.
plays a surprisingly large role in how software develop-
ers achieve code reuse in practical program development.
There are many higher level approaches to supporting code
reuse, and these may have advantages relating to correct-

63

You might also like