program design and development. steps in program development define the problem –inputs, outputs,...

21
Program Design and Development

Post on 15-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Program Design and Development

Page 2: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Steps In Program Development

• Define the Problem– Inputs, outputs, processes

• Outline the solution– Major steps

– Major subtasks

– Major control structures (repetition loops)

– Major variables

– Mainline Logic

Page 3: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Steps in PD Continued

• Develop Algorithm

– Using pseudocode and flowcharts

• Test Algorithm

• Code into programming language

• Run complier

• Document and maintain the program

Page 4: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Types of Programming

• Structured/Top Down Programming– Starting with solution and working into more complex

details

• Modular Design– Grouping tasks together by function

• Structure Theorem– Elimination of GOTO, replacement with IF-THEN-

ELSE

Page 5: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Algorithm Definition

• Lists the steps involved in accomplishing a task

• Written in simple english and not a formal document

– An algorithm must be

• Lucid, precise, and unambiguous

• Give the correct solution in all cases

• Eventually end

Page 6: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Pseudocode

• Essentially it is structured english and formalized to look like high-level computer languages

– Statements are written in simple english

– Each instruction is written on a single line

– Keywords and indentations are used to signify control structures

– Each set of instructions is written from top to bottom with only one entry and one exit

– Groups of statements may be formed into modules and that group given a name

Page 7: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Program Data

• Variables, constants, and literals

• Integer - 16

– Byte length - 8

– Short integer - 32

– Long integer - 64

• Real

– Float – single precision

– Double – double precision

• Character

• Boolean

Page 8: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Data Structures

• Record

• File

• Array

• String

Page 9: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Basic Computer Operations

• A computer can receive information

– “READ” and “GET”

• A computer can put out information

– “PRINT”, “WRITE”, “PUT”, “OUTPUT”, and “DISPLAY”

• A computer can perform arithmetic actions

– + for ADD

– - for SUBTRACT

– * for MULTIPLY

– / for DIVIDE

– () for PARENTHESES

Page 10: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Basic Computer Options Cont.

• A computer can assign a value to a variable or memory– To give an initial value use “INITALISE” or “SET”

– To assign a value use ‘=‘

– To keep a piece of information for later use ‘SAVE’ or ‘STORE’

• A computer can compare variables and select one of two alternative actions– Use of IT THEN and ELSE

– Actually it can select multiple actions

• A computer can repeat a group of actions– DOWHILE

Page 11: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

The Structure Theorem

• Sequence– The straightforward listing of each step

• Selection– The presentation of a condition and the choice

between two actions

• Repetition– The presentation of a set of instructions to be

performed repeatedly as long as a condition is true

Page 12: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Developing An Algorithm

• Defining the Problem

– Input

– Output

– Processing

• Use Meaningful Name

Page 13: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Designing an Algorithm

• Begin with a rough sketch of steps required to solve the problem

• Use these requirements and structure theorem to establish how the processing will take place

• It is important to not start coding until the necessary steps of defining the problem and designing the solution algorithm have been solved.

Page 14: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Checking an Algorithm

• Choose simple input test case

• Establish what the expected result should be

• Make a table of relevant variable names

• Walk through the test case

• Continue the process until the algorithm is correct

Page 15: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Selection Control Structures

• Used to illustrate a choice between two or more actions

• Simple IF statement

• Simple selection with null false branch (null ELSE statement)

• Combined selection (IF/AND)

• Nested IF Statement

– Linear nested IF statement

Page 16: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

The CASE Structure

• Another way of expressing a linear nested IF statement

• Can often appear cumbersome

Page 17: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Repetition Control Structures

• Developed because many programs require the same logic to be repeated for several sets of data.

• Example– DOWHILE condition p is true

• Statement block

– ENDO

Page 18: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

DOWHILE Loop Processing

• The logical condition p is tested

• If condition p is found to be true, the statements listed in the statement block will be executed once. Control is returned to the retesting of condition p.

• If condition p is found to be false, control passes to the next statement after ENDDO and no further processing takes place within the loop.

Page 19: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Two important DOWHILE considerations

• Testing of the condition is done at the beginning of the loop.

• The only way to terminate the loop is to render the DOWHILE consideration false.

Page 20: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

REPEAT_UNTIL Structure

• Is the exact opposite of the DOWHILE

• Condition is checked at the end as opposed to the beginning

• Counted repetition

• Question—is any method better than another?

Page 21: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks

Time for Practice