34
. Transformation from design representations into programs 設設設設設設設設設設設設設設 () In this part you will learn: 設設設設設 () Transformation of DFDs DFD 設設設Transformation of hierarchical DFD s 設設設設 DFD 設設設Transformation of data definitions 設設設設設設設設設 ()

8 . Transformation from design representations into programs (設計からプログラムへの変換)

  • Upload
    beyla

  • View
    44

  • Download
    2

Embed Size (px)

DESCRIPTION

8 . Transformation from design representations into programs (設計からプログラムへの変換). In this part you will learn: (主な内容) Transformation of DFDs ( DFD の変換) Transformation of hierarchical DFDs (階層的な DFD の変換) Transformation of data definitions (データ定義の変換). 8.1 Transformation of DFDs ( DFD の変換). - PowerPoint PPT Presentation

Citation preview

Page 1: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8 . Transformation from design representations into programs

(設計からプログラムへの変換)

In this part you will learn: (主な内容)

Transformation of DFDs ( DFD の変換)Transformation of hierarchical DFDs (階層的なDFD の変換)Transformation of data definitions (データ定義の変換)

Page 2: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.1 Transformation of DFDs( DFD の変換)

Problem:

Design(DFD)

Program(Java)

Transform

Data flow Control flow

Structured Object-Oriented

Page 3: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

Let us consider the following DFD: (次の DFD を考えましょう)

General strategy for transformation: (変換の方法)Define a class for each DFD. (一つの DFD に対して、一つのクラスを定義する)All of the data stores occurring in the DFD are declared as instance variables of the class. (データ倉庫はクラスのインスタンス変数で実装する)Each process of the DFD is defined as a method of the class.( DFD のプロセスは、クラスのメソッドで実装する)

AB

C

a1

a2 a3

a4

s

Page 4: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

• The data flow connections between processes can be implemented as method invocations (or method calls) in the class. (データフローは、メソッドの呼び出しで実装する)

Page 5: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.1.1 Transformation of a simple DFD with no stores

(データ倉庫を持たない DFD の変換)

A

B

Ca1

a2 a3

a4

Let G denote this DFD.

The feature of this DFD is that each process hasonly one output data flow. (この DFD の特徴は、プロセスが一つの出力データフローしか持たない)

Page 6: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.1.1.1 Specific strategy 1 (具体的な変換方法)

class G {

a2_type A(a1_type a1){ Produce a2 based on a1; return a2; }

a3_type B(a2_type a2){ Produce a3 based on a2; return a3; }

a4_type C(a3_type a3){ Produce a4 based on a3; return a4; }

a4_type F(a1_type a1){ a2_type a2; a3_type a3; a4_type a4; a2 = A(a1); a3 = B(a2); a4 = C(a3);

return a4;}

}

Page 7: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.1.1.2 Specific strategy 2 (具体的な変換方法)

class G {

a2_type A(a1_type a1){ Produce a2 based on a1; return a2; }

a4_type C(a3_type a3){ Produce a4 based on a3; return a4; }

a4_type B(a1_type a1){ a2_type a2; a3_type a3; a4_type a4; a2 = A(a1); Produce a3 based on a2; a4 = C(a3);

return a4;}

}

Page 8: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.1.1.3 Specific strategy 3 (具体的な変換方法)

class G {

a3_type B(a2_type a2){ Produce a3 based on a2; return a3; }

a4_type C(a3_type a3){ Produce a4 based on a3; return a4; }

a4_type A(a1_type a1){ a2_type a2; a3_type a3; a4_type a4; Produce a2 based on a1; a3 = B(a2); a4 = C(a3);

return a4;}

}

Page 9: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.1.2 Transformation of a complex  DFD with no stores (データ倉庫を

持たない複雑な DFD の変換)Let G1 denote the following DFD:

A

B

C

D

a1a2

a3

a5

a4

a6

a7

The feature of this DFD is that some processeshave more than one output data flows. (この DFD の特徴は、あるプロセスが二つ以上の出力データフローを持つ)

Page 10: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

DFD G1 is transformed into the following class:class G1 {

a1_type a1;

a2_type a2;

a3_type a3;

a4_type a4;

a5_type a5;

a6_type a6;

a7_type a7;

void A() { Produce a2 and a3 based on a1; } void B() { Produce a4 and a5 based on a2; } void C() { Produce a6 based on a3 and a4; } void D() { Produce a7 based on a5 and a6; }

a7_type F() { A(); //produce a2 B(); //produce a4 and a5 C(); //produce a6 D(); //produce a7

return a7;}

Note that the order of B()and C() in the body of methodF cannot be reversed. That is,C(); B() is not correct.

Page 11: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.1.3 Transformation of DFDs with stores (データ倉庫を持つ DFD の

変換)Let G2 denote the following DFD:

A Bs1a1 a2

Process A updates store s1 while process B reads data from store s1.

Page 12: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

DFD G2 is transformed into the following class: ( DFD  G2 は、次のクラスへ変換した)

class G2 { s1_type s1; void A(a1_type a1) { Update s1 based on a1; } a2_type B() { a2_type a2; Produce a2 based on s1; return a2; }}

Page 13: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.2 Transformation of hierarchical DFDs (階層的な DFD の変換)

A Ba1 a2 a3

High level DFD D1

A1

A2

A3a1

b1 b2

a2

The decomposition D2 of process A

Page 14: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

The general transformation strategy: (一般な変換し方)

Transform each DFD by following the guidelines illustrated previously. (以前に議論した変換方法により DFD を変換する)If a process is decomposed into a DFD, the method implementing the process can be defined by calling the methods implementing the processes in its decomposition. ( DFD に分解されたプロセスをメソッドの呼び出しに実装する)

The program outline transformed from thehierarchical DFD given on the previous page is given on the next page.

Page 15: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

class D1 { a2_type A(a1_type a1) { a2_type a2; //local variable Produce a2 based on a1; return a2; } a3_type B(a1_type a1) { a3_type a3; a2_type a2; //local variable a2 = A(a1); Produce a3 based on a2; return a3; }}If we consider the decomposition of process A, another class can

be used.

Page 16: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

class D1 { a2_type A(a1_type a1) { a2_type a2; //local variable b1_type b1; b2_type b2; b1 = A1(a1); b2 = A2(b1); a2 = A3(b2); return a2;

} a3_type B(a1_type a1) { a3_type a3; a2_type a2; //local variable a2 = A(a1); Produce a3 based on a2; return a3;

}}

//Produce a2 based on a1

Page 17: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.3 Transformation of Data definitions (データ定義の変

換)The transformation includes two aspects:

Transformation of elementary data items. (基本データ項目の変換)Transformation of composite data items. (複合データ項目の変換)

Page 18: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.3.1 Transformation of elementary data items (基本デ

ータ項目の変換)nat0 int

nat int

int int

real double

string String

Enumeration Vector or array of String

n..m int

Notice that the above transformation is only a guideline.

Page 19: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

8.3.2 Transformation of composite data items (複合データ項目の変換)1. Transformation of compositions:( 合成の変換) Guideline:

A composition can be transformed into a class where each

  component of the class is declared as an instance variable.

 (合成はクラスへ変換し、合成の部品データ項目がそのクラスのインスタンス変数へ変換する)

Page 20: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

For example, Let student be a composite data item defined as follows: (例えば、s tudent は次のように定義されている)

student = name + id + age + height + weight +         education

This composition is transformed into the class:( この合成データ項目は、下記のようなクラスへ変換される)

Page 21: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

class Studentty { String name; int id; int age; double height; double weight; Educationty education;}Then student must be declared as an instance variable of Studentty wherever appropriate: (そして、 student はイン

スタンス変数として次のように宣言される必要がある)

Studentty student; This declaration can be an instance variable of a class, a form

al parameter or a local variable of a method. (この宣言は、クラスのインスタンス変数としても出来るし、メソッドの仮引数又はローカル変数としても出来る)

Page 22: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

2. Transformation of options (選びデータ項目の変換) Guideline:

An optional data item in a composition should be treated the same as normal data item. (合成の部品データ項目は、普通(つまり、選ばない)のデータ項目として実装する)

For example, consider the composition: (次の事例を考え よう) a = x + (y) + z

Where y is an optional data item.

It is transformed into the class: (次のクラスへ変換される)

Page 23: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

class Aty {

type1 x;

type2 y;

type3 z;

}

Then data item a should be declared as: (そして、データ項

目 a は、次の通りに宣言する必要がある)

Aty a;

Page 24: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

3. Transformation of choices (選択データ項目の変換) Guideline: A choice of data item can be transformed into a   class where each data item involved in the choice is

declared as an instance variable of the class. (選択データ項目は、クラスへ変換される。ただし、選択されるデータ項目が、そのクラスの普通のインスタンス変数へ変換される)

For example, consider: (次の選択データ項目を考えよう ) gender = [male | female] Data item gender is transformed into the class: (データ項目 gender を次のクラスへ変換される)

Page 25: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

class Genderty { boolean male; boolean female; }

Then data item gender is declared as:( そして、 gender は次の

通りに宣言される)

Genderty gender;

Another way of transformation for this particular choice is: (データ項目 gender のもう一つの変換しかたは、次の通

りである)

boolean gender;

Page 26: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

4. Transformation of iterations (反復データ項目の変換)

Guideline:

An iteration of data items can be transformed into a subclass of

  Vector. (反復データ項目は Vector クラスのサブクラスへ変換されることができる)

Page 27: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

For example, let’s consider the definition: (次の事例を考えよう)

education = {course}

This definition can be transformed into the following class : (データ項目 education は、次のクラスへ変換できる)

class Educationty extends Vector { public Educationty() { super(); }}

Page 28: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

Then data item education can be declared as: (そして、

education は、次の通りに宣言する必要がある)

Educationty education;

Thus, education will be able to hold as many objects (e.g., courses) as possible.

Page 29: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

Notice(注意事項)

1. There are no general rules for transformations from DFDs into program structures, because the semantics of DFDs is not precise. ( DFD の操作意味が明確に定義していないため、 DFD をプログラムへの変換の一般のルールがまだ確立していない)

2. There are many ways to transform data definitions. (データ項目の定義の変換しかたは、唯一でない)

3. The discussions about transformations from DFDs and   data definitions into programs only present guidelines, not precise formulas. (上記の DFD とデータ項目の

変換は、一般のルールでなく、ガイドラインだけである)

Page 30: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

Exercise 6 (練習6)1. Transform the following DFD into a program

structure. (次の DFD をプログラム擬似コードへ変換しなさい)

2. Transform the following DFD into a program structure. (変換しなさい)

A Bc1 c2 c3

A1A2

A3c1c2

c3c4

b

Page 31: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

3. Transform the following hierarchical DFDs into a program structure. (次の階層的な DFD をプログラムの擬似コードへ変換しなさい)

high level DFD

    The decomposition of process P

1

P2

Q

1.1

P11.2

P2

1.3

P3b1a1

a1 a2 a3

a2

b3b2

Page 32: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

4. Transform the composite data item teacher into a type and variable declaration in a program language (e.g., Java). (次のデータ項目 teacher の定義をJava の型と変数へ変換しなさい)

teacher = id + name + {course} + {class} course = title + credit class = classname + numberOfStudent

where all of the undefined data items involved in the definition of teacher are regarded as elementary data items. (ここで明確定義していない全てのデータ項目は、基本データ項目として考えられる)

Page 33: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

Small project 1.4(小プロジェクト)

Transform the DFD of the “Personal Information Management System” designed in small project 1.1 into a Java program pseudocode. ( Personal Information Management System の DFD を Java

プログラム擬似コードへ変換しなさい)

Page 34: 8 . Transformation from design representations into programs (設計からプログラムへの変換)

Submission date: January 15 , 200 7 .

(提出日:2007年1月15日)Submission place: TA 又は情報科学部事務室(提出先: TA 又は情報科学部事務室)Submission contents: Design documentation and Ja

va pseudocode that are produced in small project 1.1, 1.2, 1.3, and 1.4.

(提出内容:小プロジェクト 1.1, 1.2, 1.3, 及び1.4 で作成された設計書と Java プログラム擬似コード)