上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Computational Thinking and Approach Lecture 9 Dr.Jialiang LU Jialiang.lu@situ.edu.cn
Computational Thinking and Approach Lecture 9 Dr. Jialiang LU Jialiang.lu@sjtu.edu.cn
上海充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Real-world problem SIMULATION AND DESIGN
SIMULATION AND DESIGN Real-world problem
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Computer simulation o Simulation can solve real-world problems by modeling real-world processes to provide otherwise unobtainable information. Computer simulation is used to predict the weather,design aircraft,create special effects for movies,etc. 3
3 Computer simulation • Simulation can solve real-world problems by modeling real-world processes to provide otherwise unobtainable information. • Computer simulation is used to predict the weather, design aircraft, create special effects for movies, etc
上游通大¥ ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Software Development Process ·Analyze the problem Determine specifications ·Create a design ·Implement the design Test/Debug the program ·Maintain the program 4
Software Development Process • Analyze the problem • Determine specifications • Create a design • Implement the design • Test/Debug the program • Maintain the program 4
上游充通大学 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Example:Maze 7 Vaze 口回☒ ·How to represent the problem and the solutions Maze? -A path? Need of data structure Stack or Queue Reset Repair Next Import Export Auto Quit 5
Example: Maze • How to represent the problem and the solutions – Maze? – A path? • Need of data structure – Stack or Queue 5
上游充通大学 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY %4 Mining... 可☒ Example:Mining Click some grid please .. 1 1 1 ·Same questions 2 -Field 1 1 2 1 1 Mines 1 1 Flags 1 2 3 3 How to open a field 1 2 1 3 3 1 2 2 1 Set-F Clear 10 Quit U
Example: Mining • Same questions – Field – Mines – Flags – How to open a field 6
上游充通大粤 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Top-Down Design In top-down design,a complex problem is expressed as a solution in terms of smaller, simpler problems. These smaller problems are then solved by expressing them in terms of smaller,simpler problems. This continues until the problems are trivial to solve.The little pieces are then put back together as a solution to the original problem!
7 Top-Down Design • In top-down design, a complex problem is expressed as a solution in terms of smaller, simpler problems. • These smaller problems are then solved by expressing them in terms of smaller, simpler problems. • This continues until the problems are trivial to solve. The little pieces are then put back together as a solution to the original problem!
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Top-Level Design Typically a program uses the input,process, output pattern. Is this design too high level?Whatever we don't know how to do,we'll ignore for now. Assume that all the components needed to implement the algorithm have been written already,and that your task is to finish this top- level algorithm using those components. 8
8 Top-Level Design • Typically a program uses the input, process, output pattern. • Is this design too high level? Whatever we don’t know how to do, we’ll ignore for now. • Assume that all the components needed to implement the algorithm have been written already, and that your task is to finish this toplevel algorithm using those components
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Separation of Concerns At each level of design,the interface tells us which details of the lower level are important. The general process of determining the important characteristics of something and ignoring other details is called abstraction. The top-down design process is a systematic method for discovering useful abstractions. 9
9 Separation of Concerns • At each level of design, the interface tells us which details of the lower level are important. • The general process of determining the important characteristics of something and ignoring other details is called abstraction. • The top-down design process is a systematic method for discovering useful abstractions
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Summary of the Design Process 1.Express the algorithm as a series of smaller problems. 2.Develop an interface for each of the small problems. 3.Detail the algorithm by expressing it in terms of its interfaces with the smaller problems. 4.Repeat the process for each smaller problem. 10
10 Summary of the Design Process 1. Express the algorithm as a series of smaller problems. 2. Develop an interface for each of the small problems. 3. Detail the algorithm by expressing it in terms of its interfaces with the smaller problems. 4. Repeat the process for each smaller problem