正在加载图片...
700 INHERITANCE CASE STUDY:"UNDO"IN AN INTERACTIVE SYSTEM $21.2 What do such classes represent?An instance of LINE DELETION,as illustrated below,is a little object that carries with it all the information associated with an execution of the command:the line being deleted (deleted line,a string)and its index in the text (deleted line index,an integer).This is the information needed to undo the command should this be required later on,or to redo it deleted line index 45 A command "Some text" object deleted line The exact attributes-such as deleted line and deleted line index here -will See“Requirements differ for each command class,but they should always be sufficient to support the local on the solution”", variants of execute and undo.Such objects,conceptually describing the difference page 697. between the states that precede and follow the application of a command,will enable us to satisfy requirement U3 of the earlier list-storing only what is strictly necessary. The inheritance structure of command classes may look like this: execute* Command undo* COMMAND class hierarchy LINE LINE STRING INSERTION DELETION REPLACE The graph shown is flat (all proper descendants of COMMAND at the same level), but nothing precludes adding more structure by grouping command types into intermediate categories;this will be justified if such categories make sense as abstract data types,that is to say,have specific features. When defining a notion,it is always important to indicate what it does not cover. Here the concept of command does not include Undo and Redo;for example it would not make sense to undo an Undo(except in the sense of doing a Redo).For this reason the discussion uses the term operation for Undo and Redo,reserving command for operations which can be undone and redone,such as line insertion.There is no need for a class covering the notion of operation,since non-command operations such as Undo have only one relevant feature,their ability to be executed. This is a good example of the limitations of simplistic approaches to "find the objects", “The nous and the such as the famous "Underline the nouns"idea studied in a later chapter.In the verbs",page 720. specification of the problem,the nouns command and operation are equally important; but one gives a fundamental class,the other does not give a class at all.Only the abstract data type perspective-studying abstractions in terms of the applicable operations and their properties-can help us find the classes of our object-oriented systems.700 INHERITANCE CASE STUDY: “UNDO” IN AN INTERACTIVE SYSTEM §21.2 What do such classes represent? An instance of LINE_DELETION, as illustrated below, is a little object that carries with it all the information associated with an execution of the command: the line being deleted (deleted_line, a string) and its index in the text (deleted_line_index, an integer). This is the information needed to undo the command should this be required later on, or to redo it. The exact attributes — such as deleted_line and deleted_line_index here — will differ for each command class, but they should always be sufficient to support the local variants of execute and undo. Such objects, conceptually describing the difference between the states that precede and follow the application of a command, will enable us to satisfy requirement U3 of the earlier list — storing only what is strictly necessary. The inheritance structure of command classes may look like this: The graph shown is flat (all proper descendants of COMMAND at the same level), but nothing precludes adding more structure by grouping command types into intermediate categories; this will be justified if such categories make sense as abstract data types, that is to say, have specific features. When defining a notion, it is always important to indicate what it does not cover. Here the concept of command does not include Undo and Redo; for example it would not make sense to undo an Undo (except in the sense of doing a Redo). For this reason the discussion uses the term operation for Undo and Redo, reserving command for operations which can be undone and redone, such as line insertion. There is no need for a class covering the notion of operation, since non-command operations such as Undo have only one relevant feature, their ability to be executed. This is a good example of the limitations of simplistic approaches to “find the objects”, such as the famous “Underline the nouns” idea studied in a later chapter. In the specification of the problem, the nouns command and operation are equally important; but one gives a fundamental class, the other does not give a class at all. Only the abstract data type perspective — studying abstractions in terms of the applicable operations and their properties — can help us find the classes of our object-oriented systems. "Some text" deleted_line_index deleted_line 45 A command object See “Requirements on the solution”, page 697. Command class hierarchy * LINE_ … execute* undo* INSERTION LINE_ DELETION COMMAND STRING_ REPLACE “The nouns and the verbs”, page 720
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有