Alexander Repenning and Corrina Perrone
Total Page:16
File Type:pdf, Size:1020Kb
Combining programming by example and real-world analogies, users create new behavior out of existing behavior. Programming BYAnalogous Examples Why do end users need to program? Anyone can become overwhelmed trying to cope with information in a world flooded by information. In light of the ubiquity of computer networks, the information challenge for end users is no longer about accessing information but about processing it. The direct-manipulation para- digm, popularized in the 1980s, begins to break down when they are unable to directly manipulate the sources or their information, Programming by example (PBE) is a pow- such as the location of their files on a haed erful end-user-programming paradigm drive or the emails in their in-boxes. enabling users without formal training in End-user programming is emerging as a programming to create sophisticated pro- crucial instrument in the daily information- grams. PBE environments create programs processing struggle [8]. Such programming for end users by observing and recording soft- allows customized personal information pro- ware behaviors as they manipulate informa- cessing. But few end users have the back- tion on the graphical user interface (GUI) ground, motivation, or time to use traditional level. For example, in Microsoft Word, PBE programming approaches or the means to mechanisms allow users to build macros. hire professional programmers to create pro- Here, we explore the problem of PBE grams for them. Simple forms of end-user reuse, or how users can reuse old program programming include email filters to clean behavior. A user might find a PBE-generated up email by directing specified emails into program useful but may need to either gener- separate folders and spreadsheets to explore, alize or modify it for a related but different say, the total cost of a new house. task. Program reuse is a well-known software Alexander Repenning and Corrina Perrone 90 March 2000/Vol. 43, No. 3 COMMUNICATIONS OF THE ACM Figure 1. Creating a PBE application to format all occurrences of the “Fax:” into “Fax Number:” The GUI level (left) shows a document edited with a find-and-replace dialogue box; the program level (right) shows a Visual Basic editor. design problem. Reuse problems hamper the pro- atic, because users are required to have at least a ductivity of a wide range of software projects— minimal understanding of the program-level rep- from individual end-user programmers to large resentations—if they want to be able to adapt distributed teams of software developers. In the these representations to their needs. For end users PBE context, reuse poses even more complex with no previous exposure to programming in issues. While PBE initially shields end users from Visual Basic or even to programming in general, having to deal with programming issues, reuse this transition may be too complex and leave forces them to leap cognitively between two lev- them frustrated. Frustrated, they may give up on els of representation: the idea of end-user programming and continue to solve their original problems manually over The GUI level. This level features familiar win- and over again for years. dows, icons, and menus. For instance, in a Analogies are powerful cognitive mechanisms word processing application, such as Word, people use to construct new knowledge from this level represents content directly manipu- knowledge they’ve already acquired and under- lated by users with such operations as the typ- stand. When analogies are used with PBE, the ing of new text, the formatting of text, and result is a new end-user programming paradigm the use of cursor keys to navigate through combining the elegance of PBE to create pro- a document. grams and the power of analogies to reuse exist- The program level. This level captures user ing programs. We call the combination of PBE manipulations directly into programs so users and analogies “programming by analogous exam- can replay them. In Word, this level incorpo- ples.” Analogies are an effective representation rates Visual Basic. User manipulations are level bridging the GUI and program levels. recorded as Visual Basic scripts; users then Two detailed examples help us explore the assign scripts to keyboard commands or to reuse problem. In the first, we created a Word user-defined toolbar commands. macro for repetitive reformatting in order to understand macro reuse. We chose this particular The PBE representation chasm mirrors the example not because the Word macro recording difficulty users have comprehending the map- mechanism is the most sophisticated PBE sys- ping between the GUI level and the program tem, but because Word has an enormous user level. In reuse, this chasm is especially problem- base, and readers may be able to relate more read- COMMUNICATIONS OF THE ACM March 2000/Vol. 43, No. 3 91 ily to use and reuse issues in the Word context. In to modify the macro to reformat not just the the second example, we built a SimCity-like simula- Fax: but also the Address: fields in Figure 1. tion using the AgentSheets simulation authoring To modify this macro through the “Record” func- tool [11] from AgentSheets, Inc., of Boulder, Colo.; tion, a user would have to overwrite the old macro, this tool provides an end-user programming go through the same actions that were recorded ear- approach considerably more accessible than Visual lier, and then record the desired additional behavior. Basic. We’ve found that even when the program To be able to reuse existing macros, making them level is relatively accessible, analogies are still needed useful in more general situations, end users have to as a PBE reuse mechanism. drop from the GUI level (Figure 1, left) to the pro- As PBE techniques become more widely adopted gram level (Figure 1, right). According to in both commercial and research systems, end users Microsoft’s own Word documentation: “Recorded incrementally construct and edit new behavior and macros are great when you want to perform exactly commands as needed. As in conventional program- the same task every time you run the macro. But ming approaches, the effective reuse of new behavior what if you want to automate a task in which actions is limited by the vary with the situation, underlying represen- or depend on user tations. These repre- As in conventional programming input … ? To create sentations run the powerful automations, risk of presenting approaches, the effective you should learn to end-user program- program in Visual mers with the same reuse of new behavior is Basic for Applica- copy-paste-modify tions.” and inherit-reuse limited by the underlying There is a large cog- problems that pro- nitive chasm between fessional pro- representations. the two levels. The grammers have GUI one provides only struggled with for limited options for years. What makes reuse even more problematic in a reuse. Even though advanced reuse requires PBE situation is that the programs that need to be making a transition to the program level, no inter- modified for reuse are machine generated, typically mediate steps are provided to take the user from the containing little information as to how they might simple recording mechanism to the Visual Basic be changed. programming language. At the GUI level, users are The reuse scenario in Figure 1 involves an end limited in reuse to copying macros as black boxes user trying to automatically reformat an address list. into other documents or to making macros gener- Word and other applications allow for modular ally available to all documents. At the program modification through a macro mechanism. Users are level, code may be copied, pasted, and modified given an interface to program macros by PBE with the same difficulty as these commands are through a menu command called “Record New invoked in any other object-oriented program. At Macro.” Additional support is given by the macro- this point, the user has jumped from the comfort- editing toolbar and menu functions. Once a macro able environment of direct manipulation at the is named and assigned to a toolbar icon or to a key- GUI level directly into the uncomfortable or down- board command, it is created simply by performing right frustrating program level. the desired task—repetitive reformatting in our example. The system records keystrokes and com- How Analogies Bridge the Chasm piles the command into Visual Basic. The command The AgentSheets simulation authoring tool helps can then be invoked by anyone editing a document. explain how analogies in a PBE system can bridge End users want to modify regularly and, hence, the chasm between the GUI level and the program reuse a macro with additional, related actions, then level. In AgentSheets, end users can build SimCity- assign the entire new set of changes to the same key- like simulations and export them as interactive Java board command. Mechanisms are built into Word applets. (For a detailed description of AgentSheets, for renaming the macro, thus copying the same see www.agentsheets.com/userforum-publications. behavior, but any modification to an existing macro html.) must be done through the Visual Basic program- AgentSheets combines PBE with graphical ming language. For instance, how would a user have rewrite rules into an end-user programming para- 92 March 2000/Vol. 43, No. 3 COMMUNICATIONS OF THE ACM Figure 2. Programming a train to follow a track by example in AgentSheets. When the user moves a train on a track at the GUI level (left) AgentSheets records the movement (including context) and represents it at the program level (right) as a rule. digm. Graphical rewrite rules (GRRs), which are An Analogy (Making Cars also used in such systems as Cocoa/KidSim and Cre- Move Like Trains) ator, are powerful languages for expressing the con- In an application called Sustainopolis used by urban cept of change in a visual representation.