Programming by Analogous Examples

Alexander Repenning and Corrina Perrone
AgentSheets Inc. and
Center of LifeLong Learning & Design Department of Computer Science
Campus Box 430
University of Colorado, Boulder CO 80309 303 492-1349, ralex@cs.colorado.edu

Introduction

Why do end-users need to program? In a world with an ever-increasing flood of information people become overwhelmed trying to cope with it. With the ubiquity of computer networks the information challenge is no longer about accessing information but processing it. The direct manipulation paradigm, popularized in the 1980s, begins to break down when it is no longer feasible to directly manipulate the sources of information such as the location of all the files on your hard disk or all the emails in your inbox.

End-user programming [8] is becoming a crucial instrument in the daily information-processing struggle. End-user programming is a form of programming done by the end-user to customize information processing. Most computer end-users do not have the background, motivation or time to use traditional programming approaches nor do they typically have the means to hire professional programmers to create their programs. Simple forms of end-user programming include the use of email filters to clean up your email by directing specified emails into separate folders, or the use of spreadsheets to explore the total cost of your new house.

Programming by Example (PBE) is a powerful end-user-programming paradigm enabling computer users without formal training in programming to create sophisticated programs. PBE environments create programs for end-users by observing and recording as users manipulate information on a GUI level. For instance, in Microsoft Word™ PBE is used to build macros.

The focus of this paper is the problem of Programming by Example reuse. A user may find the PBE-generated program useful but may need to either generalize it or modify it for a related yet different task. Program reuse is a well-known software design problem [4]. Reuse problems hamper productivity of a wide range of software projects all the way from individual end-user programmers to large distributed teams of software developers [12]. In the context of Programming by Example reuse poses even more complex issues. While initially PBE shields end-users from having to deal with programming issues, reuse will force them to leap cognitively between two levels of representations:

o The GUI Level: This is the level of representation featuring windows, icons, and menus familiar to users. For instance, in the case of a word processor application such as Microsoft Word ™, this is the level that represents content directly manipulated by users with operations such as; typing in new text, formatting text, using cursor keys to navigate through a document, and so forth.

o The Program Level: This is the level of representation that captures user manipulations into programs so that they can be replayed by the users. In the case of Word this is the level of Visual Basic. Manipulations by users are recorded as Visual Basic scripts. Users assign scripts to keyboard commands or to user-defined toolbar commands.
The PBE representation chasm describes how difficult it is for users to comprehend the mapping between the GUI and the Programming level. In reuse this chasm is especially problematic since users – in order to adapt representations at the programming level to their needs – will be required to have at least a minimal understanding of the programming level representations. For the end-user with no previous exposure to programming in general or to programming in Visual Basic this transition may be too complex and result in frustration. As a consequence, the user may just give up on the idea of end-user programming and continue to solve their original problem manually again and again for years.

Analogies are powerful cognitive mechanisms that people use to construct new knowledge from knowledge already acquired and understood. When analogies are used with PBE, the result is a new end-user programming paradigm combining the elegance of PBE to create programs with the power of analogies to reuse programs. The combination of PBE with Analogies is called Programming by Analogous Examples, or PBAE. Analogies are an effective representation level bridging the GUI level with the Program level.

In this article we portray the reuse problem with two detailed examples. In the first example a Microsoft Word™ macro to do repetitive reformatting is created and reusability of macros is explored. This example is chosen not because the Word macro recording mechanism is the most sophisticated PBE system but because Word has a large user base and consequently readers may best be able to relate to use/reuse issues in this context. In the second example a SimCity™-like simulation is built using the AgentSheets® [11] simulation authoring tool. AgentSheets provides an end-user programming approach that is considerably more accessible to most users than Visual Basic. We will show that even if the Program level is more accessible there is still a need for analogies as a PBE reuse mechanism. Throughout these examples Programming by Analogous Examples is contrasted with existing reuse mechanisms known from OOP such as inheritance.

Keywords:

agents & intelligent systems, end-user programming, interactive simulations, programming by example, programming by demonstration