160 likes | 179 Views
Chapter 1 (Cont..) Programming Lifecycle. OBJECTIVES. Introduce the general step programmers go through to develop computer programs and software Explain the phases in the system development life cycle. Programming Life Cycle. D o c ume n t a t I o n. Problem Analysis.
E N D
Chapter 1 (Cont..) Programming Lifecycle CSC425 - Introduction To Computer Programming
OBJECTIVES Introduce the general step programmers go through to develop computer programs and software Explain the phases in the system development life cycle. CSC425 - Introduction To Computer Programming
Programming Life Cycle D o c ume n t a t I o n Problem Analysis Programs Modelling Coding Programs Testing and Debugging Maintenance CSC425 - Introduction To Computer Programming
Step 1 : Problem Analysis • Defining the problem • Identify : • 1. Input (given data) • 2. Output (the result) • 3. Process • - relation between input and output • - using formula Input Process Output CSC425 - Introduction To Computer Programming
Example Problem 1 Write a program that can input 3 integer number from user. Find the average for the number. Display all the numbers and the average Problem analysis Input : 3 numbers Process : 1. total up 3 numbers 2. Divide the number by 3 Output : 3 numbers and the average CSC425 - Introduction To Computer Programming
1. Set sum = 0, avg = 0 2. Read 3 integer number 3. Total up 3 integer number sum = a+b+c 4. Find the average avg = sum / 3 5. Display 3 integer number and average algorithm Step 2 : Programs Modeling • Planning the solution to a problem • Using algorithm, flowchart or pseudocode [Refer Problem 1] CSC425 - Introduction To Computer Programming
start sum =0 , avg = 0 Read a, b, c sum = a+b+c avg = sum / 3 Display a,b,c Display avg End [Refer Problem 1] START INPUT a,b,c sum = a+b+c avg = sum / 3 PRINT a,b,c PRINT avg END Pseudocode Flowchart CSC425 - Introduction To Computer Programming
Step 3 : Coding and programs source code • Express solution in a programming language • Translate the logic from the flowchart or pseudocode. • There are many programming languages : BASIC, COBOL, Pascal, Fortran, C, C++, Java etc • Each language has it’s own syntax (rules of language) CSC425 - Introduction To Computer Programming
Output of the program [Refer problem 1] Coding in C++ Language CSC425 - Introduction To Computer Programming
Step 4 : Testing and Debugging • Trace error either syntax or logic error • Testing • running the program with a set of data • Debugging • Trace and fixed the error CSC425 - Introduction To Computer Programming
Run-time error • Occur during program execution • Detected by compiler • Occur because of logic error or memory leak • Syntax error • Error in the structure or spelling of a statement • Detected by the compiler during compilation of the program • Example: • Missing semicolon, quote CSC425 - Introduction To Computer Programming
Logic error • Unexpected/unintentional errors resulted from flaw in the program’s logic • Produce undesired result/output • Cannot be detected by compiler • Compare the result with manual process CSC425 - Introduction To Computer Programming
Documentation • An ongoing process • Written detailed description of the program cycle and specific facts about the program • Documentation materials include : • 1. Description of the program • 2. Logic tools : flowcharts, pseudocode • 3. Data- record descriptions • 4. Program listing • 5. Testing results • 6. Comments CSC425 - Introduction To Computer Programming
Why programmers put comment? • To explain/describe the program/function/statement • To help other programmers understand the program/function/statement • 2 types of comments • Line comment: single line comment • Block comment: multiple line comment • Syntax comment is differ to certain languages CSC425 - Introduction To Computer Programming
Step 5 : Maintenance • Modification made to the finished program • Software to meet current requirement • Need to refer the previous documentation CSC425 - Introduction To Computer Programming
Accuracy Reliability A good program must have • Efficiency Maintainability Readability Usability CSC425 - Introduction To Computer Programming