The problem with Principle 2 is that it produces the longest schedule . In practice, we apply: Principle 2’: A module, M, may be unit tested (with subordinate stubs) when the probability that an interface change will occur to some module upon which M depends falls below a given threshold,
Schedule the design of independent use cases to run in parallel. For each use case: (a) identify the participating classes (b) Identify the controlling method and its interface (c) Identify the immediately subordinate methods and associated classes (d) Design the interface to subordinate methods (e) Design the details of subordinate methods by identifying the dependent classes and methods Repeat until all methods have been designed. Conduct unit testing of methods in the reverse order of their detailed design. Schedule unit testing at the earliest possible time. Schedule unit testing of dependent methods at the earliest time after completing the unit testing of all required methods.
Figure (a) illustrates a typical module in a functional architecture - the module encapsulates a particular system function. This module manages the control flow among three related computations X,Y and Z applied to three data types A, B, and C. Figure (b) illustrates the OO architecture equivalent to figure (a). In this architecture, the data types A,B, and C become object classes Class-A, Class-B, and Class-C, respectively. The services defined for these classes represent the parts of computations X,Y and Z that directly related to one of the given types. Finally, there is typically a “control object” that initiates and/or manages the flow of messages necessary to realize the original functionality. In a pure OO system, control flow management is usually distributed among one or more “active” objects. Even so, the pragmatics of efficiency usually dictate the need for some central “executive” that manages and coordinates the overall flow of messages and control flow among objects.
This figure shows the functional dependencies among services of different object classes. These dependencies are manifested when a service of some object A (perhaps the self service) sends a message to request a service of object C, which sends a message to object D, etc. Each system function or use-case scenario is realized by one or more of these “functional threads.” So, from the perspective of system integration and testing, the identification and isolation of these threads is important, for they will serve as the basis for developing test plans, procedures, and data. As depicted in the diagram above, three functional threads can be identified: (1) A.1, B.1 (2) A.2, D.2, E.1 (3) A.3, C.1 (B.2, D.1, E.2; D.3) Because of the importance of these functional threads for testing, they also become the focus of design and implementation. In fact, all design, coding, and testing activities should be structured and schedule around functional threads. Once the functional threads have been constructed, a few simple principles can be applied to develop a schedule for detailed design, coding, unit testing, and integration testing. These are illustrated on ensuing slides.
This figure shows the functional dependencies among services of different object classes. These dependencies are manifested when a service of some object A (perhaps the self service) sends a message to request a service of object C, which sends a message to object D, etc. Each system function or use-case scenario is realized by one or more of these “functional threads.” So, from the perspective of system integration and testing, the identification and isolation of these threads is important, for they will serve as the basis for developing test plans, procedures, and data. As depicted in the diagram above, three functional threads can be identified: (1) A.1, B.1 (2) A.2, D.2, E.1 (3) A.3, C.1 (B.2, D.1, E.2; D.3) Because of the importance of these functional threads for testing, they also become the focus of design and implementation. In fact, all design, coding, and testing activities should be structured and schedule around functional threads. Once the functional threads have been constructed, a few simple principles can be applied to develop a schedule for detailed design, coding, unit testing, and integration testing. These are illustrated on ensuing slides.
This figure shows the functional dependencies among services of different object classes. These dependencies are manifested when a service of some object A (perhaps the self service) sends a message to request a service of object C, which sends a message to object D, etc. Each system function or use-case scenario is realized by one or more of these “functional threads.” So, from the perspective of system integration and testing, the identification and isolation of these threads is important, for they will serve as the basis for developing test plans, procedures, and data. As depicted in the diagram above, three functional threads can be identified: (1) A.1, B.1 (2) A.2, D.2, E.1 (3) A.3, C.1 (B.2, D.1, E.2; D.3) Because of the importance of these functional threads for testing, they also become the focus of design and implementation. In fact, all design, coding, and testing activities should be structured and schedule around functional threads. Once the functional threads have been constructed, a few simple principles can be applied to develop a schedule for detailed design, coding, unit testing, and integration testing. These are illustrated on ensuing slides.
Transcript
1. Software Unit Testing Case Study: Money Class Conversation Simulation COP 4331 OO Processes for Software Development Dr. David A. Workman School of EE and Computer Science October 2, 2006
2. Hierarchical View of Design main A::One() A::Two() A::Three() B::One() C::One() B::Two() D::One() E::Two() E::One() D::Three() D::Two() Use Case #1 Use Case #3 Use Case #2
3. Design & Testing Principles A D B C Principle 1: Design should be performed “top-down” for each functional thread defined by a Use Case; that is, the interface and detailed design of a module should follow the design of all modules that functionally depend on it. Rationale: By performing interface and detailed design top-down, we ensure that all requirements flow from dependent modules toward the modules they depend on. This principle attempts to postpone detailed design decisions until all functional requirements for a module are known. Principle 2: Coding and Unit Testing should be performed “bottom-up” for a functional thread; that is, the unit testing of a module should precede the unit testing of all modules that functionally depend on it. Rationale: By performing unit testing bottom-up, we ensure that all subordinate modules have been verified before verifying the module that depends on them. This principle attempts to localize and limit the scope and propagation of changes resulting from unit testing.
4. Design & Testing Schedules Development Layers for Detailed Design and Coding Development Layers for Unit Testing See Notes Effort Time Development Schedule Build #1 (Integration Test 1) Build #2 (Integration Test 2) Build #3 (System Test)
6. Use Case Diagram: Simulator Simulation System Construct World Specify Input Simulate World Output World Objects Report Simulation Data Initialize Simulation Specify Output Simulation Input File Simulation Log File Simulation User
7. Simulation Architecture
8. Simulation Architecture: Design Template The Passive layer contains all classes that model problem data and inanimate objects of the simulated world. Agents make direct calls on passive objects, but must account for the simulation time consumed when doing so. Passive objects make direct calls to each other, if necessary. Passive objects may be passed from one Agent to another as part of a instance of some Message subclass. This layer contains all the derived subclasses of Message. These classes are used to pass data for servicing interaction events between Agents. Only recipient Agent classes know the content and use of instances of these classes. Methods of Agents receiving messages optionally take parameters which are instances of one (or more) of the Passive classes and return an instance of class Message or one of its sub-classes. Instances of the root class Message carry no data and denote signals that require some action on the part of the receiver Agent. Virtual World Message Players Agent Event 2 Passive Class Layer Message Layer Agent Layer (Active Objects) Interface and Control Layer EventMgr * 1 Other Subclasses All Active Objects * * All Passive Classes/Objects * * * This layer consists of all active object classes. Active objects must be instances of some subclass of abstract class Agent . The simulation progresses as a result of Events created and serviced by Agents. An Event has four components: a Sender agent, a Recvr agent, an instance of some Message subclass, and an event time. When one Agent wishes to interact with another, it must do so by creating an Event that defines a “future” time at which the interaction will occur. The message component defines an action to the Recevr agent and possibly data necessary to complete the action. SimModels Classes SimMgmt Classes
19. Money Class Test Driver 3 #include "IOMgmt.h" using namespace IOMgmt; #include "Money.h" int main() { InMgr finMgr("Enter Input File( Test3 ):"); ifstream& fin = finMgr.getStream(); OutMgr foutMgr("Enter Output File( Test3 ):"); ostream& fout = foutMgr.getStream(); int num_cases; fin >> num_cases; for(int I = 1; I <= num_cases; I++) { Money M; try{ fout << "Case# " << I; fin >> M; fout << ": Money = " << M << endl; }//try catch(TokenError &e){ fout << ": " << e.getMsg() << endl; }//catch }//for }//main-3
20. Testing Agent Behaviors Once the constructors, Insert, Put, Extract and Get methods have been written and tested, the way is clear to test simulation initialization and execution behaviors. There are a couple of techniques that can be used to test specific Events and consequently specific Agent behaviors. class Conversation { //Virtual World public: Conversation(); ~Conversation(); void Initialize(); void Simulate(); void WrapUp(); void Put(); private int debugOption; //new simulation input paramter int numStudents; int numEvents; int lastEvent; AGENTPTR *students; //dynamic array of Agent* MSGPTR players; //pointer to Players message. void ExtractEvent(); //private method(s) for testing };//Conversation
21. Testing Agent Behaviors Void Conversation::Conversation() { //parses image of virtual world object, Conversation. //if debugOpt = ON, then it calls ExtractEvent() } void Conversation::ExtractEvent() { //private method of Conversation //Has visibility to any data the Conversation constructor can see. //Parses the desired image of Event(s) for debugging purposes // Posts the constructed Event(s) to theEventMgr. } SimModels.cpp
25. Outline <ul><li>A Little History of Programming </li></ul><ul><li>A Little Review of Theory (COT 4210) </li></ul><ul><li>An Example Applying Theory to Practice </li></ul><ul><li>Summary and Conclusion </li></ul>
26. A Little History of Programming <ul><li>“ Flow Diagram, turing machines and languages with only two formation rules.” by Bohm and Jacopini, CACM Vol. 9, No. 5 (May 1966) </li></ul><ul><ul><li>Proved that all algorithms could be expressed using sequential execution assignment statements, conditional logic using if-then-else statements, and iteration using while statements. </li></ul></ul><ul><li>“ Goto Statements considered harmful,” by Edsgar Dijkstra , C ACM, Vol. 11, No. 3, March 1968, pp. 147-148. </li></ul><ul><ul><li>Contributions to the specification of ALGOL, 1957 – 60. </li></ul></ul><ul><ul><li>Cooperating Sequential Processes, 1966 </li></ul></ul><ul><ul><li>The THE Operating System, 1968 </li></ul></ul><ul><li>ACM/A.M. Turing Award Citation, February 5, 1999: </li></ul><ul><ul><li>“ Edsger Dijkstra was a principal contributor in the late 1950's to the development of the ALGOL, a high level programming language which has become a model of clarity and mathematical rigor. He is one of the principal exponents of the science and art of programming languages in general, and has greatly contributed to our understanding of their structure, representation, and implementation. His fifteen years of publications extend from theoretical articles on graph theory to basic manuals, expository texts, and philosophical contemplations in the field of programming languages. “ </li></ul></ul>
27. A Little Review of Theory <ul><li>Definition 1. A Deterministic Finite Automata (DFA) is a 5-tuple, M = (Q, , , q 0 , A), where Q is a finite set of states, denotes the input alphabet , q0 denotes the unique start state , A a finite, possibly empty set of Accept states , and the behavior of M is specified by its transition (computation) function : Q Q. </li></ul>We typically specify the behavior of a DFA, its d function, in the form of a State Transition Diagram such as the one shown below as an example. 1 5 4 3 2 start a b a a a a b b b b
28. A Little Review of Theory <ul><li>Definition 2. The Language Accepted by a DFA, is denoted L(M), and is given by L(M) = { x * | (q 0 , x) A } </li></ul><ul><li>where the function , : Q * Q, is an extension of the transition function to strings over the input alphabet. </li></ul>What is L(M) for the DFA, M, given below??? L(M) = { a, ab, abaaaaba, aaaaaaba, …. } 1 5 4 3 2 start a b a a a a b b b b
29. A Little More Theory <ul><li>Definition 3. The Language of Regular Expression, E ( ), over alphabet , is the set of strings over alphabet ’ = { , , , , , ( , ) } given by the inductive definition: Basis: { , } E ( ) . Inductive Rules: assume e, f E ( ), then each of the following is a member of E ( ), [1] (e)* [2] (e f) [3] (e f) </li></ul>Definition 4. The Language defined by Regular Expression, e, is denoted L[e] and is defined recursively below. Basis: L[ ] = (the empty set), and for e { }, L[ e ] = { e }. Inductive Rules: e, f, g E ( ), [1] if e = (f)*, then L[e] = L[f]* (Kleene-star operation) [2] if e = (f g), then L[e] = L[f]L[g] (Language concatenation) [3] if e = (f g), then L[e] = L[f] L[g] (Language union) Example. E ( {a,b} ) = { , , a, b, ( )*, ( )*, (a)*, (b)*, ( ), (a a), (b ), ( + ), (a +a), (b + ), … (((a(ba))+( )*)+( (( + ))*))… } Example. L[ (((a(ba))+( )*)+( (( + ))*)) ] = {aba, }
30. A Little Review of Theory <ul><li>What is the significance (relevance) of DFAs (and their theory) ? </li></ul><ul><li>What is the significance of Regular Expressions (RE)? </li></ul><ul><li>How do these mathematical abstractions apply to programming? </li></ul><ul><li>SOME ANSWERS </li></ul><ul><ul><li>DFAs are algorithmic abstractions </li></ul></ul><ul><ul><li>DFAs and REs can be used to model the lexical analysis function of real compilers </li></ul></ul><ul><ul><li>DFA’s recognize Regular languages </li></ul></ul><ul><ul><li>RE’s also define Regular Languages </li></ul></ul><ul><li>??? “Ho Hum, Yawn” </li></ul>This could be You!!!
31. Example Method (C++) <ul><li>void Server::Work() </li></ul><ul><li>{ </li></ul><ul><li>ifstream input; // input file stream </li></ul><ul><li>ofstream output; // output file stream </li></ul><ul><li>Tray tray; </li></ul><ul><li>cout << "McDonald's Implementation in C++" << endl; </li></ul><ul><li>cout << "by XXXXXXXXXX and YYYYYYYYYYY" << endl; </li></ul><ul><li>cout << endl; </li></ul><ul><li>while(1) { </li></ul><ul><li> string szInputFileName; </li></ul><ul><li> cout << "Please enter the name of the input file: "; </li></ul><ul><li> cin >> szInputFileName; </li></ul><ul><li> input.open(szInputFileName.c_str()); </li></ul><ul><li> if( !input ) alpha: { cerr << endl << "No file named " << szInputFileName << " found." << endl; } </li></ul><ul><li> else break; </li></ul><ul><li>} </li></ul><ul><li>} //Server:: Work </li></ul>Insert Segment A (from next slide 1 2 3 5 4 6 16 A Basic Block of code is a sequence of declaration , assignment , and method call statements, that may optionally end with a goto or contional goto statement.
33. Example Method (C++) 1 2 8 6 5 3 10 15 12 17 Exception exit Normal exit System exit 9 11 14 F T F F F F T T T T Notes: This is an example of a program flow graph, the subject of Bohm and Jacopini’s theorem. Even though this algorithm was written using a “structured style”, the flow graph is not completely structured in the purest sense since there are multiple method exits due to exceptions. 16 7 4 13
34. Example Method (C++) 1 2 8 6 5 3 10 15 12 Exception exit Normal exit 9 11 14 F T F F F F T T T T Note: We have modified the structured version to violate the principles of structured design ( 13 => 5 ). To Re-Structure we apply the theory of DFAs and REs as follows: (1) All conditional nodes become “states” in a DFA. (2) Transitions between states are labeled with the sequential computation that connects any pair of conditional nodes. (3) Unique transition sequences become “letters” in the DFA alphabet. ! 16 7 4 13
35. Example Method (C++) a = 123 b = (4T)523 c = (4F)6 d = (7T)8 e = (9T)(10)(15) f = (9F) g = (11T)(12)(15) h = (11F) i = (13T523) j = (13F) k = (7F) start Exception exit Normal exit 9 11 14 a b c k d e f g h j i E 4 = a + E 4 b + E 13 i E 7 = E 4 c + E 9 e + E 11 g E 9 = E 7 d E 11 = E 9 f E 13 = E 11 h E 14 = E 13 j E 16 = E 7 k Define the following “alphabet” Set up a system of Regular Equations Solution for Paths = E 16 + E 14 E 16 = ab*c[d ( e + f (g + hib*c)) ]*k E 14 = ab*c[d ( e + f (g + hib*c)) ]*dfhj Paths = ab*c[d ( e + f (g + hib*c)) ]* (k+dfhj) 16 7 4 13
36. Expression => Code { boolean X; 1;3; //a (2 = true) while( 4 ) { 5; 3 } //b* 6; //c X := true; // Boolean variable for exception handling while ( X and 7 ) { //7T 8; //d if( 9 ) { //9T 10; 15 //e } else { //9F = f if( 11 ) { //11T 12;15 //g else{ //h if( 13 ) { //13T 5; 3 //i while( 4 ) { 5; 3} //b* 6; //c = (4F)6 } else X = false; //13F = exception condition }//11 - else }//9 - else }// while(7 and X) if( not X ) throw(exception); //j = abnormal end } //k = normal end Equivalent Structured Code a = 123 b = (4T)523 c = (4F)6 d = (7T)8 e = (9T)(10)(15) f = (9F) g = (11T)(12)(15) h = (11F) i = (13T523) j = (13F) k = (7F) Solution for Paths = E 16 + E 14 E 16 = ab*c[d ( e + f (g + hib*c)) ]*k E 14 = ab*c[d ( e + f (g + hib*c)) ]*dfhj Paths = ab*c[d ( e + f (g + hib*c)) ]* (k+dfhj)
37. Summary & Conclusion <ul><li>Summary (What are the main points?) </li></ul><ul><ul><li>DFAs and REs are more than just (equivalent) mathematical specifications for Regular Languages and algorithms for lexical analysis, they are useful for modeling algorithms of any kind and complexity. </li></ul></ul><ul><ul><li>Using algorithms for equivalence between DFAs and REs we were able to see why Bohm and Jacopini’s theorem is true, and why Dijkstra so strongly endorced the principles of structured programming. </li></ul></ul><ul><li>Conclusion (What have we learned?) </li></ul><ul><ul><li>The “marriage” between Theory and Practice is not “on the rocks”, this couple is not “legally separated” or “divorced” with “irreconcilable differences,” they are a harmonious couple, inextricably entwined, cooperating and complementing each other. What mathematics has brought together, let no computer scientist put asunder! </li></ul></ul>
39. Outline <ul><li>A Little History of Programming </li></ul><ul><li>A Little Review of Theory (COT 4210) </li></ul><ul><li>An Example Applying Theory to Practice </li></ul><ul><li>Summary and Conclusion </li></ul>
40. A Little History of Programming <ul><li>“ Flow Diagram, turing machines and languages with only two formation rules.” by Bohm and Jacopini, CACM Vol. 9, No. 5 (May 1966) </li></ul><ul><ul><li>Proved that all algorithms could be expressed using sequential execution assignment statements, conditional logic using if-then-else statements, and iteration using while statements. </li></ul></ul><ul><li>“ Goto Statements considered harmful,” by Edsgar Dijkstra , C ACM, Vol. 11, No. 3, March 1968, pp. 147-148. </li></ul><ul><ul><li>Contributions to the specification of ALGOL, 1957 – 60. </li></ul></ul><ul><ul><li>Cooperating Sequential Processes, 1966 </li></ul></ul><ul><ul><li>The THE Operating System, 1968 </li></ul></ul><ul><li>ACM/A.M. Turing Award Citation, February 5, 1999: </li></ul><ul><ul><li>“ Edsger Dijkstra was a principal contributor in the late 1950's to the development of the ALGOL, a high level programming language which has become a model of clarity and mathematical rigor. He is one of the principal exponents of the science and art of programming languages in general, and has greatly contributed to our understanding of their structure, representation, and implementation. His fifteen years of publications extend from theoretical articles on graph theory to basic manuals, expository texts, and philosophical contemplations in the field of programming languages. “ </li></ul></ul>
41. A Little Review of Theory <ul><li>Definition 1. A Deterministic Finite Automata (DFA) is a 5-tuple, M = (Q, , , q 0 , A), where Q is a finite set of states, denotes the input alphabet , q0 denotes the unique start state , A a finite, possibly empty set of Accept states , and the behavior of M is specified by its transition (computation) function : Q Q. </li></ul>We typically specify the behavior of a DFA, its d function, in the form of a State Transition Diagram such as the one shown below as an example. 1 5 4 3 2 start a b a a a a b b b b
42. A Little Review of Theory <ul><li>Definition 2. The Language Accepted by a DFA, is denoted L(M), and is given by L(M) = { x * | (q 0 , x) A } </li></ul><ul><li>where the function , : Q * Q, is an extension of the transition function to strings over the input alphabet. </li></ul>What is L(M) for the DFA, M, given below??? L(M) = { a, ab, abaaaaba, aaaaaaba, …. } 1 5 4 3 2 start a b a a a a b b b b
43. A Little More Theory <ul><li>Definition 3. The Language of Regular Expression, E ( ), over alphabet , is the set of strings over alphabet ’ = { , , , , , ( , ) } given by the inductive definition: Basis: { , } E ( ) . Inductive Rules: assume e, f E ( ), then each of the following is a member of E ( ), [1] (e)* [2] (e f) [3] (e f) </li></ul>Definition 4. The Language defined by Regular Expression, e, is denoted L[e] and is defined recursively below. Basis: L[ ] = (the empty set), and for e { }, L[ e ] = { e }. Inductive Rules: e, f, g E ( ), [1] if e = (f)*, then L[e] = L[f]* (Kleene-star operation) [2] if e = (f g), then L[e] = L[f]L[g] (Language concatenation) [3] if e = (f g), then L[e] = L[f] L[g] (Language union) Example. E ( {a,b} ) = { , , a, b, ( )*, ( )*, (a)*, (b)*, ( ), (a a), (b ), ( + ), (a +a), (b + ), … (((a(ba))+( )*)+( (( + ))*))… } Example. L[ (((a(ba))+( )*)+( (( + ))*)) ] = {aba, }
44. A Little Review of Theory <ul><li>What is the significance (relevance) of DFAs (and their theory) ? </li></ul><ul><li>What is the significance of Regular Expressions (RE)? </li></ul><ul><li>How do these mathematical abstractions apply to programming? </li></ul><ul><li>SOME ANSWERS </li></ul><ul><ul><li>DFAs are algorithmic abstractions </li></ul></ul><ul><ul><li>DFAs and REs can be used to model the lexical analysis function of real compilers </li></ul></ul><ul><ul><li>DFA’s recognize Regular languages </li></ul></ul><ul><ul><li>RE’s also define Regular Languages </li></ul></ul><ul><li>??? “Ho Hum, Yawn” </li></ul>This could be You!!!
45. Example Method (C++) <ul><li>void Server::Work() </li></ul><ul><li>{ </li></ul><ul><li>ifstream input; // input file stream </li></ul><ul><li>ofstream output; // output file stream </li></ul><ul><li>Tray tray; </li></ul><ul><li>cout << "McDonald's Implementation in C++" << endl; </li></ul><ul><li>cout << "by XXXXXXXXXX and YYYYYYYYYYY" << endl; </li></ul><ul><li>cout << endl; </li></ul><ul><li>while(1) { </li></ul><ul><li> string szInputFileName; </li></ul><ul><li> cout << "Please enter the name of the input file: "; </li></ul><ul><li> cin >> szInputFileName; </li></ul><ul><li> input.open(szInputFileName.c_str()); </li></ul><ul><li> if( !input ) alpha: { cerr << endl << "No file named " << szInputFileName << " found." << endl; } </li></ul><ul><li> else break; </li></ul><ul><li>} </li></ul><ul><li>} //Server:: Work </li></ul>Insert Segment A (from next slide 1 2 3 5 4 6 16 A Basic Block of code is a sequence of declaration , assignment , and method call statements, that may optionally end with a goto or contional goto statement.
47. Example Method (C++) 1 2 8 6 5 3 10 15 12 17 Exception exit Normal exit System exit 9 11 14 F T F F F F T T T T Notes: This is an example of a program flow graph, the subject of Bohm and Jacopini’s theorem. Even though this algorithm was written using a “structured style”, the flow graph is not completely structured in the purest sense since there are multiple method exits due to exceptions. 16 7 4 13
48. Example Method (C++) 1 2 8 6 5 3 10 15 12 Exception exit Normal exit 9 11 14 F T F F F F T T T T Notes: We have modified the structure version to make it violate the principles of structured design ( 13 => 5 ). To Re-Structure we apply the theory of DFAs and REs as follows: (1) All conditional nodes become “states” in a DFA. (2) Transitions between states are labeled with the sequential computation that connects any pair of conditional nodes. (3) Unique transition sequences become “letters” in the DFA alphabet. ! 16 7 4 13
49. Example Method (C++) a = 123 b = (4T)523 c = (4F)6 d = (7T)8 e = (9T)(10)(15) f = (9F) g = (11T)(12)(15) h = (11F) i = (13T523) j = (13F) k = (7F) start Exception exit Normal exit 9 11 14 a b c k d e f g h j i E 4 = a + E 4 b + E 13 i E 7 = E 4 c + E 9 e + E 11 g E 9 = E 7 d E 11 = E 9 f E 13 = E 11 h E 14 = E 13 j E 16 = E 7 k Define the following “alphabet” Set up a system of Regular Equations Solution for Paths = E 16 + E 14 E 16 = ab*c[d ( e + f (g + hib*c)) ]*k E 14 = ab*c[d ( e + f (g + hib*c)) ]*dfhj Paths = ab*c[d ( e + f (g + hib*c)) ]* (k+dfhj) 16 7 4 13
50. Expression => Code { boolean X; 1;3; //a (2 = true) while( 4 ) { 5; 3 } //b* 6; //c X := true; // Boolean variable for exception handling while ( X and 7 ) { //7T 8; //d if( 9 ) { //9T 10; 15 //e } else { //9F = f if( 11 ) { //11T 12;15 //g else{ //h if( 13 ) { //13T 5; 3 //i while( 4 ) { 5; 3} //b* 6; //c = (4F)6 } else X = false; //13F = exception condition }//11 - else }//9 - else }// while(7 and X) if( not X ) throw(exception); //j = abnormal end } //k = normal end Equivalent Structured Code a = 123 b = (4T)523 c = (4F)6 d = (7T)8 e = (9T)(10)(15) f = (9F) g = (11T)(12)(15) h = (11F) i = (13T523) j = (13F) k = (7F) Solution for Paths = E 16 + E 14 E 16 = ab*c[d ( e + f (g + hib*c)) ]*k E 14 = ab*c[d ( e + f (g + hib*c)) ]*dfhj Paths = ab*c[d ( e + f (g + hib*c)) ]* (k+dfhj)
51. Summary & Conclusion <ul><li>Summary (What are the main points?) </li></ul><ul><ul><li>DFAs and REs are more than just (equivalent) mathematical specifications for Regular Languages and algorithms for lexical analysis, they are useful for modeling algorithms of any kind and complexity. </li></ul></ul><ul><ul><li>Using algorithms for equivalence between DFAs and REs we were able to see why Bohm and Jacopini’s theorem is true, and why Dijkstra so strongly endorced the principles of structured programming. </li></ul></ul><ul><li>Conclusion (What have we learned?) </li></ul><ul><ul><li>The “marriage” between Theory and Practice is not “on the rocks”, this couple is not “legally separated” or “divorced” with “irreconcilable differences,” they are a harmonious couple, inextricably entwined, cooperating and complementing each other. What mathematics has brought together, let no computer scientist put asunder! </li></ul></ul>
Be the first to comment