4. The process specification (プロセス仕様) You will learn:(次の内容を学び) The concept of process specification(プロセス仕 様の概念) Notations for process specification (プロセス仕 様記法) 4.1 What is process specification? (プロセス仕様とは) (1) The problem:(問題点) Processes in a DFD are not defined in detail. Therefore, it is almost impossible to understand the meaning of the DFD precisely and accurately.(DFDでは、プロセスの機 能を定義していない) (2) The definition of process specification:(プロセス仕様 の定義) Description: a process specification is a document for the process that specifies what to do in transforming its inputs to outputs. (プロセス仕様とは、入力データフ ローを出力データフローへの変換に何をするということ を明確に定義する文書である) (3) What kinds of processes need to be specified?(どんなプ ロセスに仕様を書く必要があるか) Only the lowest level processes that do not have decompositions in a hierarchy of DFDs need to be specified, because they have no definitions in the DFD hierarchy at all.(階層的DFDのなかで分解されていない プロセスだけに仕様を書く必要がある) Processes that are decomposed into lower level DFDs do not need to be specified, because they are actually defined by their decompositions. (分解されたプロセスに対して、 分解されたDFDによるそのプロセスを定義されているの で、仕様を書く必要がない) For example, in the following DFD hierarchy, processes 2 and 3 do not need a specification, whereas processes 3.1, 2.2.1, 2.2.2, 2.2.3, and so on need to be defined. b a T1 T2 The System c T3 Figure 0 the context diagram a d e b 2 1 f h s 4 3 g c Figure 1 the decomposition of process The System d h e j 2.1 2.2 i 3.1 b 3.3 f Figure 2 3.2 s g 2.3 h k 3.4 l Figure 3 j 2.2.1 h x 2.2.2 y 2.2.3 Figure 4 b 4.2 Notations for process specification (プロセス仕様記法) We introduce the following most commonly used notations:(次の三つの仕様記法を紹介する) Pre and post-condition notation(事前条件と事後 条件の記法) Structured English(構造化英語) Decision table(意思決定表) 4.2.1 Pre and post-condition notation (事前条件と事後条件の記法) The primary idea of writing process specification using pre and postcondition notation: (事前条件と事後条件の記法の基本的な考え かた) A process can be defined by giving a pre-condition and post-condition. The pre-condition describes a constraint on the input data flows before the execution of the process, while the post-condition provides a constraint on the output data flows after the execution. (プロセスの機能を事前条件 と事後条件により定義できる。事前条件は、プロセスの入 力に対しての制限であり、事後条件は、プロセスの出力に 対しての制限である) Syntax for a process specification: this notation is a simplified version of process specification notation used in the SOFL specification language.(プロセス 仕様の文法。SOFL仕様言語のプロセス仕様記法を使う) SOFL stands for Structured Object-oriented Formal Language. (SOFLは、 Structured Object-oriented Formal Languageと意味する) process processName(input data flows) output data flows ext stores pre condition1 post condition2 end_process For example, let’s take the three processes in the following DFD as an example to show how the pre and post-condition notation is used to define processes:(次のDFDのプロセス仕様を考えよ) expenses-file 7.2 total-exp month 7.1 Provide Month Find All Related Items 7.3 items-list Calculate Total Expense total-amount process Provide-Month() month pre true post month = a month number obtained from the input device. end_process; process Find-All-Related-Items(total-exp, month) items-list ext expenses-file pre total-exp command is available and 1 <= month <= 12 post items-list = all of the items that are purchased within the requested month, obtained from the expenses-file. end_process; process Calculate-Total-Expense(items-list) total-amount pre true post total-amount = add up all of the prices for all of the items recorded in items-list. end_process; 4.2.2 Structured English (構造化英語) Structured English is English with structure. That is, it is basically English, but there are restrictions on the structure of sentences. The goal of applying such restrictions is to achieve a reasonable balance between the precision of formal programming languages and the casual informality and readability of the English texts. (構造化英語は、構造が明確である英語の表現である) Structured English includes two kinds of sentences:(構造 化英語は、次の二つの語句を含む) Basic sentences(基本語句) Compound sentences(複合語句) Basic sentences(基本語句) A basic sentence may be one of the following three kinds:(基本語句 は、次の三つの種類の語句を含む) An algebraic equation. (代数方程式)For example, x = (y * z) / (q + 4) a = b ** 2 + d/2 A simple imperative sentence consisting of a verb and object. There is no restriction on verbs and objects. (動詞と目的語から形成され た命令語句)For example, Calculate total-amount Input x A mixture of the both. (以上の二種類の語句の組合せ)For example, Compute total-amount = item1.price + itme2.price + item3.price A list of verbs that are often used in Structured English: (次の動詞は、構造化英語に良く使われる) Get (or Accept or Read) Put (or Display or Write) Find (or Search or Locate) Add Subtract Multiply Divide Compute Delete Validate Move Replace, Set, Sort Compound sentences (複合な語句) A compound sentence is one of the following:(複合 な語句は、次の種類を含む) Sequence of sentences(順序語句) Block sentence(ブロック 語句) Conditional sentences(条件語句) Multiple choice sentence(多数選択語句) Iteration sentences(反復語句) (1) Sequence of sentences (順序語句) Syntax:(文法) S1; S2; S3; Example: a function to register an item data in the expenses-file:(expenses-fileに一つのデー タ項目を登録する構造化英語) Get item-d; Register item-d in expenses-file; Add item-d.price to total-expense; (2) Block sentence (ブロック 語句) Block sentence is used to group a sequence of sentences into a single sentence. Syntax:(文法) begin sentence-1; sentence-2; sentence-3 end; Example,(例え) begin Get item-d; Register item-d in expenses-file; Add item-d.price to total-expense; end; (3) Conditional sentences (条件語句) Conditional sentences include if-then and if-then-else sentences: Syntax:(文法) if condition then sentence; end-if; or if condition then sentence-1 else sentence-2 end-if; Example:(例え) (1) if 1<= month <= 12 then Display items-d purchased in this month end-if; (2) if 1<= month <= 12 then Display items-d purchased in this month else Display warning message end-if; (4) Multiple choice sentence (多数選択語句) Syntax:(文法) do case variable value-1, value-2: sentence-1; value-3, value-4: sentence-2; …… value-9, value-10: sentence-10; otherwise: sentence; end-case; Example: (例え) do case input /* to the Personal Expenses Management System */ item-reg: Register item-d; single-item-d: Display all of the items of this kind; total-exp: Output the total expense; all-item-d: Display all of the items data in expenses-file; otherwise: Give warning message; end-case; (5) Iteration sentences (反復語句) Iteration sentences include while-do and do-while sentences. Syntax:(文法) while condition do sentence-1 end-while; do sentence-1 while condition end-while; In both while-do and do-while sentences, sentence-1 is executed until the condition becomes false. The only difference between them is that sentence-1 is firstly executed after evaluating the condition as true in while-do sentence, whereas the first execution of sentence-1 in do-while sentence is done before evaluating the condition. Examples:(例え) while items-list <> empty do begin Get next item-d; Display item-d end end-while; do begin Read item-d; Register item-d in expenses-file end while item-d.name <> “end” end-while; 4.2.3 Decision table Decision table describes that actions are taken based on a combination of certain conditions or values. Decision table is in particular effective in defining processes that produce some output or take actions based on complex conditions. General format of a decision table: Rules Conditions or variables Actions Each column shows a rule, indicating what actions are taken under what conditions. Example of decision table 1 2 3 Presence >= 10 Y Y N Exam-grade C B D Project-score >= 60 Get credit Y X N X Get no credit N = No X = Take or perform Y A Y X X X Recommend award Y = Yes Y 4 C = grade C B = grade B A = grade A This decision table can be translated into the equivalent Structured English: if Presence >= 10 and Exam-grade = C and Project-grade >= 60 then Get credit else if Presence >= 10 and Exam-grade = B and Project-grade < 60 then Get credit else if Presence < 10 and Exam-grade = D and Project-grade >= 60 then Get no credit else if Presence >= 10 and Exam-grade = A and Project-grade >= 60 then begin Get credit; Recommend award end end-if; Advantages of decision table The designer can concentrate on one rule at a time. The decision table does not imply any particular form of implementation. This will give the programmer freedom in choosing most efficient implementation strategy. The decision table can be automatically transformed into a program structure. However, whether the program is executable or not depends on if all of the involved conditions can be evaluated and all of the actions can be executed automatically. Exercise 4 1. Write the process specifications for the processes Receive-Request, Check-Password, Withdraw, and Show-Balance given in Exercise 2.1, using the following three notations, respectively. (1) Pre and post-condition notation (2) Structured English (3) Decision table 2. Use structured English to describe the following decision table. 1 work-hours >= 8 position publication <= 5 2 Y N Y P P P RA Y N Y N X DECREASE bonus GIVE award N = No X X X P = Professor RA = Research Assistant X = Take or perform 4 Y INCREASE bonus Y = Yes 3 3. Translate the following Structured English expression into a decision table. if x > 5 and y > x + 1 and z > x + y then begin Compute sum = x + y + z; Output sum; end else begin Compute sum = x * y * z; Output sum; end; Small project 1.3 Use Structured English to write process specifications for all the three processes involved in the hierarchical DFDs resulted from small project 1.1.
© Copyright 2024 ExpyDoc