1 / 34

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 (データ定義の変換). 8.1 Transformation of DFDs ( DFD の変換).

beyla
Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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(データ定義の変換)

  2. 8.1 Transformation of DFDs(DFDの変換) Problem: Transform Program (Java) Design (DFD) Data flow Control flow Structured Object-Oriented

  3. a2 a3 B a1 A a4 C Let us consider thefollowing 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のプロセスは、クラスのメソッドで実装する) s

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

  5. 8.1.1 Transformation of a simple DFD with no stores(データ倉庫を持たないDFDの変換) a2 a3 B a1 A a4 C Let G denote this DFD. The feature of this DFD is that each process has only one output data flow.(このDFDの特徴は、プロセスが一つの出力データフローしか持たない)

  6. 8.1.1.1 Specific strategy 1(具体的な変換方法) classG { 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; } }

  7. 8.1.1.2 Specific strategy 2(具体的な変換方法) classG { 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; } }

  8. 8.1.1.3 Specific strategy 3(具体的な変換方法) classG { 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; } }

  9. 8.1.2 Transformation of a complexDFD with no stores(データ倉庫を持たない複雑なDFDの変換) Let G1 denote the following DFD: B a2 a5 a1 A a7 D a4 C a3 a6 The feature of this DFD is that some processes have more than one output data flows.(このDFDの特徴は、あるプロセスが二つ以上の出力データフローを持つ)

  10. 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 method F cannot be reversed. That is, C(); B() is not correct. 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;

  11. 8.1.3 Transformation of DFDs with stores(データ倉庫を持つDFDの変換) Let G2 denote the following DFD: a1 A B a2 s1 Process A updates store s1 while process B reads data from store s1.

  12. DFD G2 is transformed into the following class:(DFDG2は、次のクラスへ変換した) 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; } }

  13. 8.2 Transformation of hierarchical DFDs(階層的なDFDの変換) a1 a2 a3 A B High level DFD D1 a2 a1 A3 A1 b1 b2 A2 The decomposition D2 of process A

  14. 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 the hierarchical DFD given on the previous page is given on the next page.

  15. 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.

  16. 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

  17. 8.3 Transformation of Data definitions(データ定義の変換) The transformation includes two aspects: • Transformation of elementary data items.(基本データ項目の変換) • Transformation of composite data items.(複合データ項目の変換)

  18. 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.

  19. 8.3.2 Transformation of composite data items(複合データ項目の変換) • Transformation of compositions:(合成の変換) Guideline: A composition can be transformed into a class where each component of the class is declared as an instance variable.  (合成はクラスへ変換し、合成の部品データ項目がそのクラスのインスタンス変数へ変換する)

  20. For example, Let student be a composite data item defined as follows:(例えば、studentは次のように定義されている) student = name + id + age + height + weight + education This composition is transformed into the class:(この合成データ項目は、下記のようなクラスへ変換される)

  21. 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 formal parameter or a local variable of a method.(この宣言は、クラスのインスタンス変数としても出来るし、メソッドの仮引数又はローカル変数としても出来る)

  22. 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: (次のクラスへ変換される)

  23. class Aty { type1 x; type2 y; type3 z; } Then data item a should be declared as:(そして、データ項 目aは、次の通りに宣言する必要がある) Aty a;

  24. 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を次のクラスへ変換される)

  25. 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;

  26. Transformation of iterations(反復データ項目の変換) Guideline: An iteration of data items can be transformed into a subclass of Vector.(反復データ項目はVectorクラスのサブクラスへ変換されることができる)

  27. 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(); } }

  28. 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.

  29. Notice(注意事項) • 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とデータ項目の変換は、一般のルールでなく、ガイドラインだけである)

  30. Exercise 6(練習6) • Transform the following DFD into a program structure.(次のDFDをプログラム擬似コードへ変換しなさい) 2. Transform the following DFD into a program structure.(変換しなさい) c1 c2 c3 B A b c4 A3 c1 A1 c3 c2 A2

  31. a1 a3 a2 3. Transform the following hierarchical DFDs into a program structure.(次の階層的なDFDをプログラムの擬似コードへ変換しなさい) high level DFD The decomposition of process P 2 Q 1 P a1 a2 b1 1.3 P3 1.1 P1 1.2 P2 b3 b2

  32. 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. (ここで明確定義していない全てのデータ項目は、基本データ項目として考えられる)

  33. 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プロ グラム擬似コードへ変換しなさい)

  34. Submission date: January 15, 2007. (提出日:2007年1月15日) Submission place: TA又は情報科学部事務室 (提出先: TA又は情報科学部事務室) Submission contents: Design documentation and Java 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プログラム擬似コード)

More Related