Near-term memory (NTM) is proposed as a construct for analyzing the memory that experts build up and use as they solve a problem in their domain of expertise. Large amounts of information are processed in such situations, and any particular detail could become important later, so performance is facilitated by maintaining long-term memory access to as much detail as possible. Precise analysis of such memory is difficult to achieve with experimentation or observation alone, so computational simulation is used as the analytical method. A computational process model grounded in cognitive theory (Soar) is constructed to fit extensive fine-grained behavioral data from an expert programmer. The model's structures and processes are then inspected for insights into NTM. Structurally, the model's NTM consists of fine-grain perceptual, semantic, and episodic items whose availability is tied to cues from the encoding context. Quantitatively, much more detail enters NTM than is ever retrieved, but when retrieval does occur it can change the course of behavior. To illustrate applications of the construct, the model is used to examine how a cluttered interface might impose cognitive costs by increasing retrieval demands on memory. Near-term memory 3 Near-Term Memory in Programming: A Simulation-Based Analysis Expertise in programming has been quantified in terms of tens or hundreds of thousands of rules making up a programmer's domain knowledge (Brooks, 1977) , consistent with estimates of tens of thousands of chunks comprising expertise in other domains like chess (Chase & Simon, 1973) . However, such analyses of expertise emphasize long-term, semantic knowledge, built up over years, and not only through simple practice but through deliberate reflection and inference (Ericsson & Lehmann, 1996) . A largely unexamined aspect of expertise in programming is the information accumulated in episodic memory moment-to-moment as performance proceeds. Various studies suggest that people are faced with large amounts of detail to be stored in memory as they perform a complex task Ericsson & Kintsch, 1995; Jeffries, Turner, Polson, & Atwood, 1981) . Moreover, the lag between encoding and needing any particular item could range from seconds to minutes or perhaps hours, placing a premium on retention. Finally, the likelihood of needing a particular item is hard to predict, making it risky to encode selectively. Understanding how the memory system responds to these constraints is important for many reasons. For example, episodic details acquired during task performance eventually become the semantic structures of expertise, so understanding the structure of episodic memory and how it evolves should help us improve how experts are trained. Such an understanding would also be a basis for memory-friendly designs of tools like programming environments. Studying memory in expert problem solving is difficult precisely because the task environment is complex and requires the problem solver to process a large amount of information. This complexity makes it impractical to discover the contents of memory experimentally -indeed, from the time of the nonsense syllable (Ebbinghaus, 1885(Ebbinghaus, /1964 Near-term memory 4 experimenters have attempted to isolate memory from the influence of knowledge (arguably to detriment of theory; Young & Lewis, 1999) . And although other common analytical methods are not burdened by the need for experimental control, these have their own problems. For example, task analysis (e.g., Kirwan & Ainsworth, 1992) attempts to specify the structure of the task environment, and is often augmented with naturalistic observation (Hutchins, 1995a; Zsambok & Klein, 1997) or interviews to elicit what operators (think they) do as they perform. These approaches produce useful insights, but as measurement tools they are not sensitive enough to reveal the underlying memory processes with any precision. A more detailed form of observation is microgenetic analysis (Siegler, 1991) , which attempts to track cognitive behavior at a fine grain, often across multiple trials on the same task to allow inferences about what is being learned. However, the very richness of detail that places episodic memory at the center of expert problem solving also places an overwhelming bookkeeping burden on the analyst using any of these approaches to model behavior. The challenge, then, is to study episodic memory in expert problem solving with both precision and completeness, coping with the fact that these two requirements interact to multiply the cost of the analysis. Precision entails a detailed representation of what a problem solver is thinking moment by moment, and completeness requires that this detailed representation achieve broad coverage of the information being processed. This coverage is critical because the validity of model is jeopardized by every item of information processed by the problem solver but not represented in the model. One approach to achieving precision and completeness concurrently is to simulate behavior computationally. Simulation adds precision because the knowledge attributed to the problem solver, and the information flow between problem solver and environment, is Beyond supporting precision and completeness, computational simulation is perhaps the only reliable vehicle for bringing cognitive theory to bear on complex behavior. With the advent of programmable cognitive theories (Anderson & Lebiere, 1998; Newell, 1990) , the analyst can not only simulate behavior, but can subject the simulation to the same cognitive constraints faced by humans. Such constraints, for example limitations on the capacity and span of working memory, help to ensure that the model is a valid representation of cognition. More importantly, and as I illustrate in this article, theoretical constraints on a model of behavior generate novel insights into the underlying cognitive structures and processes. Applied to expert problem solving, cognitive simulation produces sufficient insight into human memory to warrant naming a new construct. The construct of near-term memory combines the analytical goals of long-term working memory (Ericsson & Delaney, 1999; Ericsson & Kintsch, 1995) and other non-computational approaches to studying real-world memory (Neisser, 1976; Venturino, 1997; Yntema, 1963) with the methodological and theoretical leverage of cognitive simulation. The moniker "near-term" derives from the structure of the information stored, which combines attributes of short-term and long-term memory. Short-term memory as typically studied in psychology is largely episodic, in that it maintains items in context (for example, the fact that the syllable BAZ appeared in the list of words given at study time). In contrast, long-term memory is typically analyzed for its Near-term memory 6 organization and semantic content, as illustrated by the standard approaches to expertise mentioned above. Near-term memory bridges the gap, storing large quantities of episodic detail and linking it to semantic knowledge in such a way that critical items can be retrieved if the need arises and the cues are available. Near-term memory is bound by two constraints flowing from the nature of the task interacting with the nature of cognition. The first constraint is that problem solving in a complex, information-rich environment demands relatively non-selective storage of information in memory. When someone is truly searching a problem space, essentially any item of information could turn out to be important later and therefore beneficial to recall at the right time. In contrast, if the problem solver knew ahead of time what information would become relevant later, arguably he or she would not be searching a problem space as much as exhibiting skilled or over-learned behavior. One consequence of the non-selectivity constraint is that near-term memory stores structurally diverse kinds of information, including perceptual chunks, recoded semantic knowledge, and episodic pointers into the environment. A second consequence is that encoding is a continual process, because there is continual processing of task-specific information and because essentially any item processed now could be important to remember later. The general implication is that near-term memory contains vast amounts of information, much of which is never retrieved, but any of which could be retrieved and could critically affect the course of behavior. The second constraint on near-term memory concerns the actual circumstances of retrieval. In a complex task that involves problem-solving search or a dynamic environment, an item could become relevant essentially at any time. Thus the lag between encoding and retrieval can be many minutes long. Moreover, there is no guarantee that maintenance or Near-term memory 7 elaboration will be possible in the interim, because the retention interval will generally be filled with other cognitive activity. The consequence is that encoding specificity (Tulving, 1983 ) is one of the main factors governing the availability of a memory item. The encoding specificity principle says that when an item is encoded, other items of working memory are encoded with it, and will serve as cues for the item later. If there is time to elaborate an item, the set of cues encoded with it grows and retrieval will be easier. However, expert problem solving generally involves concentrated or event-filled activity that affords little slack time in which to elaborate an item, so the item's cues will remain limited. Should the right cue enter working memory in the future, for example if the environment is dynamic and the cue simply appears, then the target item will seem to pop to mind. The general implication is that expert problem solving depends critically on cues that retrieve details about the task, and hence on the semantic knowledge and perceptual information of which these cues are comprised. Near-term memory, then, is memory of the task that expert problem solvers (in this study a programmer) build up as they perform the task. The main functional requirement on near-term memory is that it capture as many of the intermediate products of problem solving as possible for use later, because any particular detail could become relevant again. Measurement and analysis of near-term memory are performed on a computational cognitive model. Because this model is strongly constrained by theory and data, and because it must run, it fills in details that cannot be discovered through experimentation or simple observation. The rest of the article fleshes out these ideas and their implications. The first section describes the programming episode that furnishes the behavioral data. The following sections describe a computational model of this episode and constraints on the model's learning and memory processes, and assess the model's validity in representing the target behavior. The Near-term memory 8 next step is to analyze the model's near-term memory quantitatively and structurally. Finally, the general discussion draws implications for expert-novice differences in programming and inspects the model to reveal low-level but pervasive cognitive costs of environmental clutter. The programming session from which the sample behavior was drawn was one session in a long-term, multi-person project to create a large natural-language comprehension system (this system will be referred to simply as the program). The programmer contributed regularly to implementation, and was thoroughly familiar with the theory behind the program and the production-system language in which the program was implemented. Her high-level goal for the session, during which she worked alone, was to make a specific change to the implementation. The session lasted 80 minutes, during which the programmer stepped through a single run of the program interactively at a fine grain. The interaction took place in a GNU Emacs process buffer, a virtual teletype with a prompt at the bottom at which a user can communicate commands to a running process. The process with which the programmer interacted was a production-system interpreter into which the program had been loaded. In addition to issuing stepping commands to advance the program, the programmer issued query commands to request various kinds of state information from the interpreter, including the contents of data structures, the contents of the runtime stack, and elements of code.
Altmann, for instance, analyzed a ten minute interval of an expert programmer performing a task and used computational simulation to study the near-term memory REF .
Near-Term Memory in Programming: A Simulation-Based Analysis
Computer Science