Command object logging system for restoring documents
COPYRIGHT NOTIFICATION 
     Portions of this patent application contain materials that are subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever. 
     CROSS-REFERENCE TO RELATED PATENT APPLICATIONS 
     This patent application is related to the patent application U.S. patent application Ser. No. 07/996,171, now abandoned and continued as U.S. patent application Ser. No. 08/482,314, entitled Object Oriented Framework System, by Debra L. Orton, David B. Goldsmith, Christopher P. Moeller, and Andrew G. Heninger, filed Dec. 23, 1992, and assigned to Taligent, the disclosure of which is hereby incorporated by reference. 
     FIELD OF THE INVENTION 
     This invention generally relates to improvements in computer systems and more particularly to a system and method for a high availability document processing system. 
     BACKGROUND OF THE INVENTION 
     Document processing is currently the most prevalent application of computer technology. Examples of state of the art word processing technology include the WordPerfect® text processor and the Word text processor from Microsoft® Corporation. These products are designed to run on various operating systems and different hardware platforms. Some of the hardware platforms and operating systems are less reliable then others. To avoid loss of data or other information, these products have a backup capability that can be enabled at system setup. The backup occurs when a user specified time elapses, if a user selects to enable the capability. If the system has a failure between backups, then the information since the last backup is lost. 
     SUMMARY OF THE INVENTION 
     Accordingly, it is a primary objective of the present invention to provide a system and method for automatically saving a document by applying object oriented technology to document processing. The system automatically saves changes of a document as objects that are logged to a non-volatile store. Then, in the event of a power-loss or other problem, the document has the changes applied in the order they were saved on the log to recreate the document. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a block diagram of a personal computer system in accordance With a preferred embodiment; 
     FIGS. 2A &amp; 2B are flowcharts presenting the processing that transpires in accordance with a preferred embodiment; 
     FIG. 3 is a flowchart presenting processing that transpires when a document is restored in accordance with a preferred embodiment; and 
     FIG. 4 is a flowchart presenting the logic associated with saving a document in accordance with a preferred embodiment. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     The invention is preferably practiced in the context of an operating system resident on a personal computer such as the IBM® PS/2® or Apple® Macintosh® computer. A representative hardware environment is depicted in FIG. 1, which illustrates a typical hardware configuration of a workstation in accordance with the subject invention having a central processing unit 10, such as a conventional microprocessor, with a built in non-volatile storage 11, and a number of other units interconnected via a system bus 12. The workstation shown in FIG. 1 includes a Random Access Memory (RAM) 14, Read Only Memory (ROM) 16, an I/O adapter 18 for connecting peripheral devices such as a disk unit 20, and a diskette unit 21 to the bus, a user interface adapter 22 for connecting a keyboard 24, a mouse 26, a speaker 28, a microphone 32, and/or other user interface devices such as a touch screen device (not shown) to the bus, a communication adapter 34 for connecting the workstation to a data processing network 23 and a display adapter 36 for connecting the bus to a display device 38. The workstation has resident thereon an operating system such as the Apple System/7® operating system. 
     In a preferred embodiment, the invention is implemented in the C++ programming language using object oriented programming techniques. As will be understood by those skilled in the art, Object-Oriented Programming (OOP) objects are software entities comprising data structures and operations on the data. Together, these elements enable objects to model virtually any real-world entity in terms of its characteristics, represented by its data elements, and its behavior, represented by its data manipulation functions. In this way, objects can model concrete things like people and computers, and they can model abstract concepts like numbers or geometrical concepts. The benefits of object technology arise out of three basic principles: encapsulation, polymorphism and inheritance. 
     Objects hide, or encapsulate, the internal structure of their data and the algorithms by which their functions work. Instead of exposing these implementation details, objects present interfaces that represent their abstractions cleanly with no extraneous information. Polymorphism takes encapsulation a step further. The idea is many shapes, one interface. A software component can make a request of another component without knowing exactly what that component is. The component that receives the request interprets it and figures out according to its variables and data, how to execute the request. The third principle is inheritance, which allows developers to reuse pre-existing design and code. This capability allows developers to avoid creating software from scratch. Rather, through inheritance, developers derive subclasses that inherit behaviors, which the developer then customizes to meet their particular needs. 
     A prior art approach is to layer objects and class libraries in a procedural environment. Many application frameworks on the market take this design approach. In this design, there are one or more object layers on top of a monolithic operating system. While this approach utilizes all the principles of encapsulation, polymorphism, and inheritance in the object layer, and is a substantial improvement over procedural programming techniques, there are limitations to this approach. These difficulties arise from the fact that while it is easy for a developer to reuse their own objects, it is difficult to use objects from other systems and the developer still needs to reach into the lower non-object layers with procedural Operating System (OS) calls. 
     Another aspect of object oriented programming is a framework approach to application development. One of the most rational definitions of frameworks come from Ralph E. Johnson of the University of Illinois and Vincent F. Russo of Purdue. In their 1991 paper, Reusing Object-Oriented Designs, University of Illinois tech report UIUCDCS91-1696 they offer the following definition: &#34;An abstract class is a design of a set of objects that collaborate to carry out a set of responsibilities. Thus, a framework is a set of object classes that collaborate to execute defined sets of computing responsibilities.&#34; From a programming standpoint, frameworks are essentially groups of interconnected object classes that provide a pre-fabricated structure of a working application. For example, a user interface framework might provide the support and &#34;default&#34; behavior of drawing windows, scrollbars, menus, etc. Since frameworks are based on object technology, this behavior can be inherited and overridden to allow developers to extend the framework and create customized solutions in a particular area of expertise. This is a major advantage over traditional programming since the programmer is not changing the original code, but rather extending the software. In addition, developers are not blindly working through layers of code because the framework provides architectural guidance and modeling but at the same time frees them to then supply the specific actions unique to the problem domain. 
     From a business perspective, frameworks can be viewed as a way to encapsulate or embody expertise in a particular knowledge area. Corporate development organizations, Independent Software Vendors (ISV)s and systems integrators have acquired expertise in particular areas, such as manufacturing, accounting, or currency transactions as in our example earlier. This expertise is embodied in their code. Frameworks allow organizations to capture and package the common characteristics of that expertise by embodying it in the organization&#39;s code. First, this allows developers to create or extend an application that utilizes the expertise, thus the problem gets solved once and the business rules and design are enforced and used consistently. Also, frameworks and the embodied expertise behind the frameworks have a strategic asset implication for those organizations who have acquired expertise in vertical markets such as manufacturing, accounting, or bio-technology would have a distribution mechanism for packaging, reselling, and deploying their expertise, and furthering the progress and dissemination of technology. 
     Historically, frameworks have only recently emerged as a mainstream concept on personal computing platforms. This migration has been assisted by the availability of object-oriented languages, such as C++. Traditionally, C++ was found mostly on UNIX systems and researcher&#39;s workstations, rather than on Personal Computers in commercial settings. It is languages such as C++ and other object-oriented languages, such as Smalltalk and others, that enabled a number of university and research projects to produce the precursors to today&#39;s commercial frameworks and class libraries. Some examples of these are InterViews from Stanford University, the Andrew toolkit from Carnegie-Mellon University and University of Zurich&#39;s ET++ framework. 
     There are many kinds of frameworks depending on what level of the system you are concerned with and what kind of problem you are trying to solve. The types of frameworks range from application frameworks that assist in developing the user interface, to lower level frameworks that provide basic system software services such as communications, printing, file systems support, graphics, etc. Commercial examples of application frameworks are MacApp (Apple), Bedrock (Symantec), OWL (Borland), NeXTStep App Kit (NEXT), and Smalltalk-80 MVC (ParcPlace) to name a few. 
     Programming with frameworks requires a new way of thinking for developers accustomed to other kinds of systems. In fact, it is not like &#34;programming&#34; at all in the traditional sense. In old-style operating systems such as DOS or UNIX, the developer&#39;s own program provides all of the structure. The operating system provides services through system calls--the developer&#39;s program makes the calls when it needs the service and control returns when the service has been provided. The program structure is based on the flow-of-control, which is embodied in the code the developer writes. 
     When frameworks are used, this is reversed. The developer is no longer responsible for the flow-of-control. The developer must forego the tendency to understand programming tasks in term of flow of execution. Rather, the thinking must be in terms of the responsibilities of the objects, which must rely on the framework to determine when the tasks should execute. Routines written by the developer are activated by code the developer did not write and that the developer never even sees. This flip-flop in control flow can be a significant psychological barrier for developers experienced only in procedural programming. Once this is understood, however, framework programming requires much less work than other types of programming. 
     In the same way that an application framework provides the developer with prefab functionality, system frameworks, such as those included in a preferred embodiment, leverage the same concept by providing system level services, which developers, such as system programmers, use to subclass/override to create customized solutions. For example, consider a multimedia framework which could provide the foundation for supporting new and diverse devices such as audio, video, MIDI, animation, etc. The developer that needed to support a new kind of device would have to write a device driver. To do this with a framework, the developer only needs to supply the characteristics and behavior that is specific to that new device. 
     The developer in this case supplies an implementation for certain member functions that will be called by the multi-media framework. An immediate benefit to the developer is that the generic code needed for each category of device is already provided by the multi-media framework. This means less code for the device driver developer to write, test, and debug. Another example of using systems framework would be to have separate I/O frameworks for SCSI devices, NuBus cards, and graphics devices. Because there is inherited functionality, each framework provides support for common functionality found in its device category. Other developers could then depend on these consistent interfaces to all kinds of devices. 
     A preferred embodiment takes the concept of frameworks and applies it throughout the entire system. For the commercial or corporate developer, systems integrator, or OEM, this means all the advantages that have been illustrated for a framework such as MacApp can be leveraged not only at the application level for such things as text and user interfaces, but also at the system level, for services such as graphics, multi-media, file systems, I/O, testing, etc. 
     Application creation in the architecture of a preferred embodiment will essentially be like writing domain-specific puzzle pieces that adhere to the framework protocol. In this manner, the whole concept of programming changes. Instead of writing line after line of code that calls multiple API hierarchies, software will be developed by deriving classes from the preexisting frameworks within this environment, and then adding new behavior and/or overriding inherited behavior as desired. 
     Thus, the developer&#39;s application becomes the collection of code that is written and shared with all the other framework applications. This is a powerful concept because developers will be able to build on each other&#39;s work. This also provides the developer the flexibility to customize as much or as little as needed. Some frameworks will be used just as they are. In some cases, the amount of customization will be minimal, so the puzzle piece the developer plugs in will be small. In other cases, the developer may make very extensive modifications and create something completely new. In a preferred embodiment, as shown in FIG. 1, an application program resident in the RAM 14, and under the control of the CPU 10, is responsible for managing various tasks using an object oriented document framework. 
     Other systems, such as the Apple Macintosh System 7, use a model that requires a user to explicitly save a document. In these systems, the user opens a document, makes some changes, and saves the document. Usually, the new version of the document replaces the old one, although some applications keep one or more past saved versions. 
     Until the user saves, the changes made exist only inside the application. If the application or system crashes, those changes are lost. Some applications store parts of their data on disk and the user may be able to recover something from those disk files. Some applications (e.g., Quicken and HyperCard on the Macintosh) effectively do an automatic save each time the user changes something. This processing prevents the user from losing work due to a crash, but the user can lose work due to an unwanted change. Other applications checkpoint a document in a separate file when the user switches pages. This prevents the user from losing work on other pages, but does nothing to prevent losing work on the active page. 
     Saveless Model 
     A preferred embodiment checkpoints each change to the document and logs it to disk. In the event of a crash, the system starts with the last &#34;saved&#34; version and replays all the changes the user made against the copy to restore the document. The resulting document is identical to the document the user had at the time of the crash. In effect, the system automatically stores a saved image and a command log. The saved image records the state of the entire document at a certain point in time, and the command log records all changes to the document since that time. 
     The basic flow of control when the user is editing the document is as follows: 
     Each time a user makes a change to a document, a copy of the command object that represents the change is placed onto the end of a queue. 
     A separate background task takes the command objects off the queue and saves them into the command log. This task executes at a lower priority to enable this action to execute when the user isn&#39;t interacting with the system to minimize impact to user productivity. 
     The command object is processed normally to change the document. 
     FIGS. 2A-2B are a flowchart presenting the processing that transpires in accordance with a preferred embodiment. Processing commences at terminal 200 and immediately passes to function block 210 to open a document by retrieving the document from a disk or other storage device. A document could include text, graphic, image, audio or other information. Decision block 220 detects changes as they are made to the document. Then, for each change made to the document, a command object is built and placed at the end of a queue in storage as shown in function block 230. Finally, a background task, shown in function block 240, is responsible for building the log in a non-volatile store based on objects in the queue. 
     The background task schematically illustrated as function block 240 is shown in more detail in FIG. 2B. In particular, the background task starts at terminal 250 and proceeds to decision block 260 where a determination is made whether the command object needs to be saved to the disk. If the command object does not need to be saved to the disk, decision block 260 directs processing back to decision block 260 where the next command object is examined. If the decision in block 260 is that the command object does need to be saved to the disk, then processing passes to block 270 in which the command object is removed from the temporary queue and saved to the command log located on the disk, After processing of block 270 is completed, processing flow returns to decision block 260 where the next command object in the queue is examined. Processing continues in this manner until all command objects in the queue are examined and stored to the disk, if appropriate. 
     When a user opens a document the following processing occurs: 
     the document&#39;s saved image is retrieved from a disk, cache or other memory. 
     If the command log is not empty, the commands in the log are replayed. 
     FIG. 3 is a flowchart presenting processing that transpires when a document is restored in accordance with a preferred embodiment. Processing commences at terminal 300 and immediately passes to function block 310 to retrieve a stored document from a disk, disk cache or other memory. A decision is then performed at decision block 320 to determine if the command log is empty. If so, then the document is complete and control is passed back at terminal 350. If not, then the commands stored in the log are replayed, in order, and applied to the document as shown in function block 330, the command log is erased at function block 340, and control is returned at terminal 350. 
     At certain points in time, the document is saved: 
     Save the entire document into the saved image. 
     Erase the command log. 
     FIG. 4 is a flowchart presenting the logic associated with saving a document in accordance with a preferred embodiment. Processing commences at terminal 400 and immediately passes to function block 410 to save the document. Then, the command log is erased at function block 420 and control is returned at terminal 430. This processing can occur at a user request, a user specified time, or automatically when a document is closed. 
     The filing architecture defines an abstract model store that contains both the saved image and a command log. A document consists of a group of separate model objects that the model store provides access to. The model objects include a document image at the level of the individual models. Typically, the model store is saved on disk, but one of ordinary skill in the art will readily recognize that the model store can reside in memory, cache, or other storage mediums. 
     While the invention has been described in terms of a preferred embodiment in a specific system environment, those skilled in the art recognize that the invention can be practiced, with modification, in other and different hardware and software environments within the spirit and scope of the appended claims.