Top-down Program Design(5/14) Pseudocode >A hybrid mixture of MATLAB and English for defining algorithms. >Independent of any programming language so it can be easily converted to any programming language Example pseudocode: Prompt user to enter temperature in degrees Fahrenheit Read temperature in degrees Fahrenheit (temp f) temp_k (in Kelvins)<(5/9)*(temp_f-32)+273.15 Write temperature in degree Kelvins @月停大学 TONGJI UNIVERSITY
➢ A hybrid mixture of MATLAB and English for defining algorithms. ➢ Independent of any programming language so it can be easily converted to any programming language ➢ Example pseudocode: Prompt user to enter temperature in degrees Fahrenheit Read temperature in degrees Fahrenheit (temp_f) temp_k (in Kelvins) (5/9) * (temp_f – 32) + 273.15 Write temperature in degree Kelvins Top-down Program Design(5/14) Pseudocode
Top-down Program Design(6/14) Testing In a large programming project,the time actually spent programming is surprisingly small. In the book The Mythical Man-Month,Frederick P.Brooks,ir suggests that in a typical large software project: 1/6 of the time is spent writing the program 1/3 of the time is spent planning what to do 1/2 of the time is spent testing @日济大学 AW TONGJI UNIVERSITY
➢ In a large programming project, the time actually spent programming is surprisingly small. ➢ In the book The Mythical Man-Month,Frederick P.Brooks,jr suggests that in a typical large software project: ✓ 1/6 of the time is spent writing the program ✓ 1/3 of the time is spent planning what to do ✓ 1/2 of the time is spent testing Top-down Program Design(6/14) Testing
Top-down Program Design(7/14) Testing >A typical testing process for large program Test individual subtasks:unit testing Add tested components one by one and test them together: build √Alpha release Beta release n√Finished program @凡两大学 AW TONGJI UNIVERSITY
➢ A typical testing process for large program ✓ Test individual subtasks: unit testing ✓ Add tested components one by one and test them together: build ✓ Alpha release ✓ Beta release ✓ Finished program Top-down Program Design(7/14) Testing
Top-down Program Design(8/14) Testing When we have written a program and it is not working, how do we debugging? >Three types of errors are found in MATLAB programs. √Syntax error Caused by the spelling errors or punctuation errors. >x=(y+3)/2) ?x=(y+3)/2) Error:Unbalanced or misused parentheses or brackets. Solution:Check spelling and punctuation 同濟大学 AW TONGJI UNIVERSITY
When we have written a program and it is not working, how do we debugging? ➢ Three types of errors are found in MATLAB programs. ✓ Syntax error Caused by the spelling errors or punctuation errors. Solution: Check spelling and punctuation Top-down Program Design(8/14) Testing
Top-down Program Design(9/14) Testing √Run-time error It occurs when an illegal mathematical operation is attempted during program execution.(For example attempting to divide by 0) >>x=pi/log(1) Warning:Divide by zero. X= Inf Solution: 2 ·Check input data Can remove“,”or add“disp'statements @月停大学 AW TONGJI UNIVERSITY
✓ Run-time error It occurs when an illegal mathematical operation is attempted during program execution. (For example , attempting to divide by 0) Solution: • Check input data • Can remove “;” or add “disp” statements Top-down Program Design(9/14) Testing