230 likes | 508 Views
Program Design and Development. 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. Steps in PD Continued. Develop Algorithm
E N D
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
Steps in PD Continued • Develop Algorithm • Using pseudocode and flowcharts • Test Algorithm • Code into programming language • Run complier • Document and maintain the program
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
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
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
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
Data Structures • Record • File • Array • String
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
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
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
Developing An Algorithm • Defining the Problem • Input • Output • Processing • Use Meaningful Name
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.
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
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
The CASE Structure • Another way of expressing a linear nested IF statement • Can often appear cumbersome
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
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.
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.
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?