design the program create a detailed description of program –use charts or ordinary language...

16
Design the program Create a detailed description of program Use charts or ordinary language (pseudocode) • Identify algorithms needed Algorithm: a step-by-step method to solve a problem or complete a task Algorithms must be: Well defined Well ordered Must produce some result Must terminate in a finite time

Upload: lauren-hill

Post on 30-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

Design the program

• Create a detailed description of program– Use charts or ordinary language (pseudocode)

• Identify algorithms needed– Algorithm: a step-by-step method to solve a problem

or complete a task

• Algorithms must be:– Well defined– Well ordered– Must produce some result– Must terminate in a finite time

Page 2: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

Documentation program

• In-program documentation (remarks)

• Program maintenance manual– For programming experts to help them fix or enhance

code written by other programmers

• Design documentation– Written by programmer to explain rationale behind

methods and code used

• Trade Study documentation– A research tool

– An attempt to find the best solution

Page 3: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

Using Flowchart Symbols and Pseudocode Statements

• Flowchart: pictorial representation of the logic

• Pseudocode: English-like representation of the logic– Example:

Page 4: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

Structured Programming

• A method for designing and coding programs in a systematic, organized manner

• It combines the principles of top-down design, modularity and the use of the three accepted control structures of sequence, repetition and selection

• Sequence, repetition and selection can be expressed in pseudocode, or with flowcharts

Page 5: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

Flowcharts• A tool for programmers to design programs

– Describes the flow of a program module’s execution with diagrams

– Completely different from hierarchy charts– Connected symbols are used to describe sequence, repetition, and selection structures

– Some prefer to use flowcharting to learn how to express algorithms, and others prefer to use pseudocode

– Many programs are designed with a combination of pseudocode and flowcharts

Page 6: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

Flowchart SymbolsWiley text: page 100Auxiliary slideMany in Powerpoint

Page 7: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

Flowchart input symbol:

Page 8: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

• Flowchart processing symbol

Page 9: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

• Flowchart output symbol:

Page 10: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

• Flowlines: – Connect the steps – Show the sequence of statements– Have arrows to show the direction

• Terminal symbol (start/stop symbol): – Shows the start and end points of the

statements– Lozenge shape

Page 11: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

Flowchart vs. Psuedocode

Page 12: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

• Back-pointing arrows show statements that will be repeated (loop)

Page 13: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

• Infinite loop: a sequence of statements that repeats forever with no escape

• Avoid infinite loops by testing for a predetermined value that means “stop processing”

• Decision: testing a value• Flowchart decision symbol: a diamond

shape, with two flowlines, one for Yes and one for No Into decision

Askquestion

Answer = Yes Answer = No

Page 14: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

• Sentinel value (or dummy value)– Does not represent real data– Signal to stop– Can be used with input from files or from users

• End-of-file (EOF) marker: – Code stored in the file that marks the end of the data– Usually used instead of a sentinel value for file input

Page 15: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

• Flowchart connector symbol:– Marks a logic transfer to another location in the

flowchart– Transfer location can be on the same page or on

another page– On-page symbol: a circle with a number or

letter to identify the matching transfer location

– Off-page symbol: a square with a pointed bottom, containing page number and a number of letter to identify the matching transfer location

Page 16: Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step

On page: from

On page: to

Off page: to