正在加载图片...
$20.4 A CRITIQUE OF THE SOLUTION 683 The flow of data execute session Level3 state initial transition execute Level 2 state is final state state state state Level 1 display read correct message process In this example the subversion of the structure comes in particular from the need to discriminate on states.All the level 1 routines must perform different actions depending on s:to display the panel for a certain state;to read and interpret a user answer(made of a number of input fields,different for each state);to determine whether the answer is correct;to output the proper error message;to process a correct answer-you must know the state.The routines will perform a discrimination of the form inspect S when Initial then when Enquiry on flights then end This means long and complex control structures and,worse yet,a fragile system: any addition of a state will require changes throughout the structure.This is a typical case of unbridled knowledge distribution:far too many modules of the system rely on a piece of information-the list of all possible states-which is subject to change. The situation is in fact even worse than it appears if we are hoping for general reusable solutions.There is an extra implicit argument in all the routines considered so far:the application-airline reservation or anything else we are building.So to make routines such as display truly general we would have to let them know about all states of all possible applications in a given computing environment!Function transition would similarly contain the transition graph for all applications.This is of course unrealistic.§20.4 A CRITIQUE OF THE SOLUTION 683 In this example the subversion of the structure comes in particular from the need to discriminate on states. All the level 1 routines must perform different actions depending on s: to display the panel for a certain state; to read and interpret a user answer (made of a number of input fields, different for each state); to determine whether the answer is correct; to output the proper error message; to process a correct answer — you must know the state. The routines will perform a discrimination of the form inspect s when Initial then … when Enquiry_on_flights then … … end This means long and complex control structures and, worse yet, a fragile system: any addition of a state will require changes throughout the structure. This is a typical case of unbridled knowledge distribution: far too many modules of the system rely on a piece of information — the list of all possible states — which is subject to change. The situation is in fact even worse than it appears if we are hoping for general reusable solutions. There is an extra implicit argument in all the routines considered so far: the application — airline reservation or anything else we are building. So to make routines such as display truly general we would have to let them know about all states of all possible applications in a given computing environment! Function transition would similarly contain the transition graph for all applications. This is of course unrealistic. execute_session initial transition execute_ state is_final display read correct message process Level 1 Level 3 Level 2 state state state state state The flow of data
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有