Download presentation
Presentation is loading. Please wait.
Published byMagnus Walton Modified over 9 years ago
1
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 1 Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers
2
Lecture Outline Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers Branching & Program Design Top-down design Pseudocode Slide 2 of 15
3
Branching & Program Design Top-Down Design – Five Design Steps Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers 1.Clearly state the problem to be solved Carefully articulate the objectives 2.Define required inputs and outputs Constraints/requirements 3.Design the algorithm to be implemented Define a simple step-by-step procedure (pseudocode?) Will use a top-down approach 4.Convert the algorithm into code (e.g., MATLAB, C, …) Replace pseudocode with actual code 5.Test the resulting program Verify and Validate the design (debugging?) Cant solve the problem If it is NOT understood!!! Goes-intos & Goes-outs! Slide 3 of 15
4
Branching & Program Design Top-Down Design – Step 1: Define the Problem Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers STEP 1: Clearly state the problem to be solved Carefully articulate the objectives o If you can not clearly define the problem then you can NOT construct a coherent solution!! Understand your target audience o Just myself? o My class / fellow engineering students? o Millions of consumers? Frequency of usage o Just for this one homework assignment? o Throughout the term? o Daily for many years? Maintenance Implications. Very different audiences. Slide 4 of 15
5
Branching & Program Design Top-Down Design - Step 2: Define the Inputs/Outputs Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers Step 2: Define required inputs and outputs Constraints / requirements o How many inputs / outputs? o What type of inputs / outputs? Data format(s)? o Valid range of the input variables? How to respond to invalid inputs? » E.g., Select an Input between 1 and 10: 66 o Where will the input(s) come from? Keyboard, file, real-time data, … o Where will the output(s) go to? Screen-text, file, plot, … Slide 5 of 15
6
Branching & Program Design Top-Down Design – Step 3: Design the Algorithm Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers Step 3: Design the algorithm to be implemented Define a simple step-by-step procedure (pseudocode?) o Use natural language description NOT MATLAB code o May require multiple passes Top-Down Algorithmic Decomposition o Break the problem down into smaller sub-problems o Define modules and sub-modules These may also have individual I/O definitions!! Slide 6 of 15
7
Branching & Program Design Top-Down Design – Step 4: Convert Algorithm to Code Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers Step 4: Convert the algorithm to code Replace pseudocode with actual code o 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, …) o This is NOT the 1 st Step!!!!!!!!!!! o E.g., Battleship Game – First step was NOT writing MATLAB code!!!!! You may run into limitations of the chosen language. Slide 7 of 15
8
Branching & Program Design Top-Down Design – Step 5: Test the Program Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers Step 5: Test the resulting program Verify and Validate the design o Verification: Are we solving the problem correctly? o Validation: Are we solving the right problem? Can be approached at a program level o More often conducted at a component/module level. Regression testing o 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!! Slide 8 of 15
9
Branching & Program Design Top-Down Design – Design Flow Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers MATLAB coding is the 2 nd to last step!! Understanding the problem is the 1 st step!! The last step in the design flow is testing. Slide 9 of 15
10
Branching & Program Design Top-Down Design - Complex System Design Flow Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers Design process for complex systems May include both hardware & software "Introduction to Rapid Software Testing" By Chris Brown, Gary Cobb, Robert Culbertson. Slide 10 of 15
11
Branching & Program Design Top-Down Design – Life Cycle of a Computer Program Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers 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 Slide 11 of 15
12
Branching & Program Design Pseudocode Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers 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: o Flowcharting o Data flow diagrams o Class diagrams Slide 12 of 15
13
Branching & Program Design Pseudocode – A Flowchart example Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers 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 Slide 13 of 15
14
Branching & Program Design Pseudocode – An Example Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers 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 Slide 14 of 15
15
Next Lecture Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers Logic Operators Slide 15 of 15
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.