正在加载图片...
$22.1 STUDYING A REQUIREMENTS DOCUMENT 721 they may be opened and closed.Then to express the useful properties of doors it suffices to include in class ELEVATOR the query and commands door_open:BOOLEAN: close door is 444 ensure not door open end; open door is “40 ensure door_open end In another variant of the system,however,the notion of door may be important enough to justify a separate class.The only resource here is the theory of abstract data types,and the only relevant question is: Is"door"a separate data type with its own clearly identified operations,or are all the operations on doors already covered by operations on other data types such as ELEVATOR? Only your intuition and experience as a designer will tell you the answer.In looking for it,you will be aided by the requirements document,but do not expect grammatical criteria to be of more than superficial help.Turn instead to the ADT theory,which will help you ask customers or future users the right questions. Chapter 21. We encountered a similar case in the undo-redo mechanism design.The discussion distinguished between commands,such as the line insertion command in a text editor,and the more general notion of operation,which includes commands but also special requests such as Undo.Both of these words figured prominently in the statement of the problem; yet only COMMAND yielded a data abstraction (one of the principal classes ofthe design), whereas no class in the solution directly reflects the notion of operation.No analysis of a requirements document can suggest this striking difference of treatment. Is a new class necessary? Another example of a noun which may or may not give a class in the elevator example is floor.Here (as opposed to the door and operation cases)the question is not whether the concept is a relevant ADT:floors are definitely an important data abstraction for an elevator system.But this does not necessarily mean we should have a FLOOR class. The reason is simply that the properties of floors may be entirely covered,for the purposes of the elevator system,by those of integers.Each floor has a floor number;then§22.1 STUDYING A REQUIREMENTS DOCUMENT 721 they may be opened and closed. Then to express the useful properties of doors it suffices to include in class ELEVATOR the query and commands door_open: BOOLEAN; close_door is … ensure not door_open end; open_door is … ensure door_open end In another variant of the system, however, the notion of door may be important enough to justify a separate class. The only resource here is the theory of abstract data types, and the only relevant question is: Only your intuition and experience as a designer will tell you the answer. In looking for it, you will be aided by the requirements document, but do not expect grammatical criteria to be of more than superficial help. Turn instead to the ADT theory, which will help you ask customers or future users the right questions. We encountered a similar case in the undo-redo mechanism design. The discussion distinguished between commands, such as the line insertion command in a text editor, and the more general notion of operation, which includes commands but also special requests such as Undo. Both of these words figured prominently in the statement of the problem; yet only COMMAND yielded a data abstraction (one of the principal classes of the design), whereas no class in the solution directly reflects the notion of operation. No analysis of a requirements document can suggest this striking difference of treatment. Is a new class necessary? Another example of a noun which may or may not give a class in the elevator example is floor. Here (as opposed to the door and operation cases) the question is not whether the concept is a relevant ADT: floors are definitely an important data abstraction for an elevator system. But this does not necessarily mean we should have a FLOOR class. The reason is simply that the properties of floors may be entirely covered, for the purposes of the elevator system, by those of integers. Each floor has a floor number; then Is “door” a separate data type with its own clearly identified operations, or are all the operations on doors already covered by operations on other data types such as ELEVATOR? Chapter 21
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有