Presentation is loading. Please wait.

Presentation is loading. Please wait.

EGR 115 Introduction to Computing for Engineers

Similar presentations


Presentation on theme: "EGR 115 Introduction to Computing for Engineers"— Presentation transcript:

1 EGR 115 Introduction to Computing for Engineers
Branching & Program Design – Part 1 Lecture 14 EGR 115 Introduction to Computing for Engineers

2 EGR 115 Introduction to Computing for Engineers
Lecture Outline Branching & Program Design Top-down design Pseudocode Lecture 14 EGR 115 Introduction to Computing for Engineers

3 Branching & Program Design Top-Down Design – Five Design Steps
Clearly state the problem to be solved Carefully articulate the objectives Define required inputs and outputs Constraints/requirements Design the algorithm to be implemented Define a simple step-by-step procedure (pseudocode?) Will use a top-down approach Convert the algorithm into code (e.g., MATLAB, C, …) Replace pseudocode with actual code Test the resulting program Verify and Validate the design (debugging?) Cant solve the problem If it is NOT understood!!! Goes-intos & Goes-outs! Lecture 14 EGR 115 Introduction to Computing for Engineers

4 EGR 115 Introduction to Computing for Engineers
Branching & Program Design Top-Down Design – Step 1: Define the Problem STEP 1: Clearly state the problem to be solved Carefully articulate the objectives If you can not clearly define the problem then you can NOT construct a coherent solution!! Understand your target audience Just myself? My class / fellow engineering students? Millions of consumers? Frequency of usage Just for this one homework assignment? Throughout the term? Daily for many years? Very different audiences. Maintenance Implications. Lecture 14 EGR 115 Introduction to Computing for Engineers

5 EGR 115 Introduction to Computing for Engineers
Branching & Program Design Top-Down Design - Step 2: Define the Inputs/Outputs Step 2: Define required inputs and outputs Constraints / requirements How many inputs / outputs? What type of inputs / outputs? Data format(s)? Valid range of the input variables? How to respond to invalid inputs? E.g., Select an Input between 1 and 10: 66 Where will the input(s) come from? Keyboard, file, real-time data, … Where will the output(s) go to? Screen-text, file, plot, … Lecture 14 EGR 115 Introduction to Computing for Engineers

6 EGR 115 Introduction to Computing for Engineers
Branching & Program Design Top-Down Design – Step 3: Design the Algorithm Step 3: Design the algorithm to be implemented Define a simple step-by-step procedure (pseudocode?) Use natural language description NOT MATLAB code May require multiple passes Top-Down Algorithmic Decomposition Break the problem down into smaller sub-problems Define modules and sub-modules These may also have individual I/O definitions!! Lecture 14 EGR 115 Introduction to Computing for Engineers

7 EGR 115 Introduction to Computing for Engineers
Branching & Program Design Top-Down Design – Step 4: Convert Algorithm to Code Step 4: Convert the algorithm to code Replace pseudocode with actual code Divide and conquer!! Build and test small pieces Progressive integration!! Final step is to “encode” the algorithm using the chosen programming language (e.g., MATLAB, C, Java, …) This is NOT the 1st Step!!!!!!!!!!! E.g., Sudoku Game – First step was NOT writing MATLAB code!!!!! You may run into limitations of the chosen language. Lecture 14 EGR 115 Introduction to Computing for Engineers

8 Branching & Program Design Top-Down Design – Step 5: Test the Program
Step 5: Test the resulting program Verify and Validate the design Verification: Are we solving the problem correctly? Validation: Are we solving the right problem? Can be approached at a program level More often conducted at a component/module level. Regression testing How do I determine the effects of an update/change? I only made a small change!!! Famous last words!! Step 5 is often the most time consuming of the five steps!! Lecture 14 EGR 115 Introduction to Computing for Engineers

9 Branching & Program Design Top-Down Design – Design Flow
MATLAB coding is the 2nd to last step!! Understanding the problem is the 1st step!! The last step in the design flow is testing. Lecture 14 EGR 115 Introduction to Computing for Engineers

10 EGR 115 Introduction to Computing for Engineers
Branching & Program Design Top-Down Design - Complex System Design Flow Design process for complex systems May include both hardware & software "Introduction to Rapid Software Testing" By Chris Brown, Gary Cobb, Robert Culbertson. Lecture 14 EGR 115 Introduction to Computing for Engineers

11 EGR 115 Introduction to Computing for Engineers
Branching & Program Design Top-Down Design – Life Cycle of a Computer Program Alpha release Objective: Identify and fix major bugs (typically internal audience) First complete version Similar to final testing after complete integration Beta release Objective: Identify and fix minor bugs (typically external audience) Engage outside testers for bugs Similar to qualification or acceptance testing in aerospace industry Lecture 14 EGR 115 Introduction to Computing for Engineers

12 Branching & Program Design Pseudocode
What is pseudocode? The design process by which we "design the algorithm (and data structures)" by decomposing the problem into more manageable sub-problems. Pseudocode is one method to design the algorithm It happens to be the method favored by the text Other methods include: Flowcharting Data flow diagrams Class diagrams Lecture 14 EGR 115 Introduction to Computing for Engineers

13 Branching & Program Design Pseudocode – A Flowchart example
Start Declare variable types READ hours, base pay rate, overtime pay rate Compute pay at base rate Hours > 40? Compute overtime bonus pay Add overtime to base PRINT results STOP Yes No Lecture 14 EGR 115 Introduction to Computing for Engineers

14 Branching & Program Design Pseudocode – An Example
The prior example in pseudocode %READ in data: hours, base pay rate, overtime pay rate %Compute pay at base rate %IF hours > 40 %Compute overtime bonus %Add to base %Print results %END Lecture 14 EGR 115 Introduction to Computing for Engineers

15 EGR 115 Introduction to Computing for Engineers
Next Lecture Logic Operators Lecture 14 EGR 115 Introduction to Computing for Engineers


Download ppt "EGR 115 Introduction to Computing for Engineers"

Similar presentations


Ads by Google