Computer Programming & Application (CSC430) - Program Development Lifecycle
Program Development Lifecycle
Objectives
- Explain the 5 steps in the Program Development Life Cycle (PDLC).
Program Development Life Cycle (PDLC)
The PDLC consists of the following steps:
- Problem Analysis
- Program Design
- Coding
- Testing and Debugging
- Maintenance
- Documentation
Problem Analysis
- A process of identifying the input, processes, and output of a program.
- Outcome: Input-Process-Output (IPO) chart as a tool.
Problem Analysis Example 1
- Problem: Write a program that can input 3 integer numbers from the user, find the average of the numbers, and display all the numbers and the average.
- Analysis:
- Input: 3 numbers
- Process:
- Total up the 3 numbers
- Divide the total by 3
- Output: 3 numbers and the average
- IPO Chart:
- INPUT: 3 integer numbers
- PROCESSING:
- Total 3 numbers
- Divide total with 3
- OUTPUT: 3 numbers, Average
Problem Analysis Example 2
- Problem: Nation’s Air force has asked you to write a program to label supersonic aircraft as military or civilian. Your program is to be given the plane’s observed speed in km/h and its estimated length in meters. For planes traveling in excess of 1100km/h, you will label those longer than 52 meters “civilian” and shorter aircraft as “military”. For planes traveling at slower speeds, you will issue an “aircraft type unknown” message.
- Analysis
- Speed
- Length
- Processing
- Validate the speed and length
- Speed > 1100km/h AND length > 52m
- Speed > 1100km/h AND length <= 52m
- Speed <= 1100km/h
- Validate the speed and length
- Output
- Classification can be one of the following values
- Civilian
- Military
- Aircraft type unknown
- Classification can be one of the following values
Program Design
- Planning the solution to a problem.
- Developing an algorithm.
- Algorithm: A precise step-by-step action to perform the overall task of the program.
- Can be represented using either flowchart or pseudo-code.
- Tools used for Program Design:
- Pseudo Code
- Flow Chart
Program Design - Flowchart
- A set of symbols and edges used in flowcharts:
- Terminal (Begin and End)
- Process
- Input/Output Operation
- Condition/Evaluation
- Direction
Program Design Example: Average of 3 Numbers
- Algorithm:
- Set ,
- Read 3 integer numbers
- Total up 3 integer numbers:
- Find the average:
- Display 3 integer numbers and average
- Flowchart: (Flowchart description - START, INPUT a, b, c, sum = a+b+c, avg = sum/3, PRINT a, b, c, PRINT avg, END)
- Pseudocode:
START INPUT a, b, c sum = a + b + c avg = sum / 3 PRINT a, b, c PRINT avg END
Program Design Example: Aircraft Classification
- Pseudocode:
START READ Speed, Length IF Speed > 1100 THEN IF Length > 52 THEN Classification = “Civilian” ELSE Classification = “Military” ENDIF ELSE Classification = “Aircraft Type Unknown” ENDIF END - Flowchart: (Flowchart description - START, READ Speed, READ Length, Speed > 1100?, Length > 52?, Classification assignments, Display classification, END)
Coding
- Implement the flowchart or pseudo code into specific programming language rules (syntax).
- Translate the logic from the flowchart or pseudo code.
- There are many programming languages: BASIC, COBOL, Pascal, Fortran, C, C++, Java, etc.
- Each language has its own syntax (rules of language).
Coding Example: 3 Integer Numbers (C++)
#include <iostream.h>
main() {
int a, b, c, sum;
float avg;
sum = 0;
avg = 0;
cout << "Input three numbers :" << endl;
cin >> a >> b >> c;
sum = a + b + c;
avg = sum / 3;
cout << a << endl;
cout << b << endl;
cout << c << endl << endl;
cout << "Average of the numbers " << avg << endl;
}
- Output of the program:
Input three numbers :
4
4
4
Average of the numbers 4.00
Testing and Debugging
- Program must be free from syntax errors.
- Use a set of test data to validate the output.
- Program must receive valid input and produce correct output.
- Trace errors, either syntax or logic errors.
- Testing: Running the program with a set of data.
- Debugging: Trace and fix the error.
Types of Errors
- Syntax Error:
- Occurs when the rules of the language are not applied.
- Can be traced by the compiler during compilation.
- Also called a “compile-time error”.
- Logic Error:
- Error in the logic of processing.
- Cannot be traced by the compiler.
- Output produced is wrong.
- Run-time Error:
- Errors caused by program instructions that require the computer to do something illegal, such as an attempt to divide a number by 0.
- The program will stop automatically and display certain messages.
Documentation and Maintenance
Documentation
- User manual.
- Written detailed description of the program cycle and specific facts about the program.
- Documentation materials include:
- Description of the program
- Logic tools: flowcharts, pseudocode
- Data-record descriptions
- Program listing
- Testing results
- Comments
Maintenance
- Modification made to the finished program software to meet current requirements.
- Need to refer to the previous documentation.
Qualities of a Good Program
A good program must have:
- Efficiency
- Accuracy
- Reliability
- Maintainability
- Readability
- Usability