Program Development Life Cycle
How a program is built in four stages, analysis, design, coding and testing, and the checks and test data that show whether it works.
WATCH IT EXPLAINED
EXPLORE IT IN 3D
The software studio
The maths club needs a program for its test marks. Take it round the whole life cycle: analyse the brief, design it, code and test it a part at a time, check the data at the test bench, and fix the bugs.
What the life cycle is for
Every program is built in four stages, always in the same order: analysis, design, coding, testing.
- Analysis
- Design
- Coding
- Testing
Each stage makes something that the next stage needs.
When a test fails, go back. Go back to coding to fix the mistake. Or go back to design if the plan itself was wrong.
Watch out:IGCSE has exactly these four stages. AS Level adds a fifth stage, maintenance, but it is not part of the IGCSE cycle.
This lesson follows one small project through every stage: a program for a maths club's test marks.
Analysis: abstraction and decomposition
Analysis finds out exactly what the problem is and what the program must do.
Analysis means working out exactly what the problem is and what the program must do. The result is a list of requirements (the things the program must do).
Analysis uses two tools:
| Tool | What it does | Example: the maths club |
|---|---|---|
| Abstraction | removes the details that do not matter, so you can focus on the ones that do | the marks matter; the colour of the test paper does not |
| Decomposition | breaks the problem into smaller parts: its inputs, processes, storage and outputs | input: the marks; output: the results |
Topic 2.1.2 teaches decomposition in full.
Design: plan before you code
Design turns the requirements into a plan that someone could write code from.
Design turns the requirements into a plan. Someone should be able to write code from it.
The syllabus names three design methods:
| Method | What it shows |
|---|---|
| Structure diagram | the parts of the program |
| Flowchart | the order of the steps, and the decisions |
| Pseudocode | the steps as statements, close to real code |
Decomposition carries on in design. Each part is split again until it is small enough to write.
The code below is the design for one part: input one valid mark. Topics 2.1.2 and 2.1.3 teach these methods.
DECLARE Mark : INTEGER INPUT Mark WHILE Mark < 0 OR Mark > 100 DO OUTPUT "Invalid. Enter a mark from 0 to 100" INPUT Mark ENDWHILE OUTPUT "Mark accepted: ", Mark
Coding and iterative testing
Write a little, test it, fix it, test again: coding and iterative testing go together.
Coding means writing the program code. At IGCSE it always goes with iterative testing (testing again and again as you build):
- Write one part.
- Test it straight away.
- Fix anything that fails.
- Test it again.
You repeat this many times. You do not write the whole program and test it once at the end.
Why? A mistake is easiest to find in the few lines you just wrote. The rest of the program already passed its tests.
Validation: is this data sensible?
Validation is an automatic check that data is sensible and follows the rules before it is accepted.
Exam:Validation is a check the program makes automatically, to test that data entered is sensible and follows the rules before it is accepted.
| Check | What it tests | Example |
|---|---|---|
| Range check | a value is between two limits | a mark from 0 to 100 |
| Length check | the number of characters | a password's length |
| Type check | the data type | a whole number |
| Presence check | something was entered | the name box is not empty |
| Format check | a pattern | two letters, then four digits |
| Check digit | a digit worked out from the other digits, checked again when the code is typed in | the last digit of a barcode |
The code below does a type check and a range check together.
DECLARE Mark : REAL INPUT Mark IF Mark = ROUND(Mark, 0) AND Mark >= 0 AND Mark <= 100 THEN OUTPUT "Accepted" ELSE OUTPUT "Rejected" ENDIF
Verification: was it typed in correctly?
Verification checks that data was typed in correctly, with no change on the way in.
Verification checks that data was entered accurately. It did not change on its way into the computer.
There are two kinds:
- Double entry check: the data is typed twice. The computer compares the two entries. If they are different, it asks for the data again.
- Visual check: the user looks at the data on the screen. They confirm that it matches the original, such as a paper form.
| Validation | Verification | |
|---|---|---|
| Asks | is it sensible? | was it typed in correctly? |
| Cannot tell | whether the data is true | whether the data is sensible |
A program needs both.
Four kinds of test data
Test each rule with four kinds of data: normal, abnormal, extreme and boundary.
Example rule: a whole number from 0 to 100.
| Kind | What it is | Example | Result |
|---|---|---|---|
| Normal | a typical value | 45 | accepted |
| Abnormal | outside the range, or the wrong type | -20, 150, "ten" | rejected |
| Extreme data | the largest or smallest value still accepted | 0 and 100 | accepted |
| Boundary data | pairs, one pair at each limit: the last accepted value and the value just past it | 0 and -1; 100 and 101 | accepted, rejected |
Exam:Give each value, and say why you chose it.
Rule: a whole number from 0 to 100
normal 45 accepted
abnormal -20, 150, "ten" rejected
extreme 0 and 100 accepted
boundary 0 and -1 accepted, rejected
100 and 101 accepted, rejectedA test plan finds the mistake
A test plan lists every test and its expected result before you run anything.
A test plan lists every test before any test is run. Each row gives:
- the test data
- its type (normal, abnormal, extreme or boundary)
- the expected result
After the run, write the actual result beside it. Is the actual result different from the expected one? That row shows an error to fix.
When every row passes, the program works for the data you chose. That does not prove it has no errors left.
Remember:Normal data rarely finds a mistake. Mistakes hide at the limits of a rule. That is why you test extreme and boundary data.
Syntax errors and logic errors
A syntax error stops the program running; a logic error runs but gives the wrong answer.
| Syntax error | Logic error | |
|---|---|---|
| What it is | breaks the grammar rules of the language | a mistake in the algorithm itself |
| Example | a misspelt keyword, or a missing ENDWHILE | > where >= was needed |
| Does it run? | not in full until it is fixed | yes, with no error message, but the result is wrong |
| Who finds it | the translator | no translator can find it |
When a translator meets a syntax error:
- a compiler reports the error before the program runs.
- an interpreter stops when it reaches that line.
To find a logic error, use test data. Or dry-run the algorithm with a trace table.
What each stage produces: the words the exam wants
Exam answers about each stage are marked on the syllabus words, so learn them.
Questions like "Describe the analysis stage" are marked on the syllabus words.
Example:In one recent exam, analysis answers got marks for abstraction, decomposition, identifying the problem and identifying the requirements.
| Stage | The words the exam wants |
|---|---|
| Analysis | abstraction, decomposition, identification of the problem and of the requirements |
| Design | decomposition, structure diagrams, flowcharts, pseudocode |
| Coding | writing program code, iterative testing |
| Testing | testing the code with test data: normal, abnormal, extreme, boundary |
- Click the stages below in the order they happen.
KEY TERMS
CHECK YOURSELF
1.A program runs without any error message but prints the wrong total. What kind of error is this?
2.A field accepts whole-number marks from 0 to 100. Which pair is BOUNDARY test data?
3.Which stage comes immediately after analysis?
4.A birth year of 3025 is entered. Which check would reject it?
5.Typing a password twice so that the computer can compare the two is: