Paper 2 Theory
1. Data Types
| Type | What it stores | Examples |
|---|---|---|
| INTEGER | whole number, no decimal | 95 94 93 21 (even −5) |
| REAL | number with decimal part | 95.1 101.0 9.3 1.6 |
| STRING | alphabets, numbers, symbols (text in " ") | "Computer Science" |
| CHAR | single character in ' ' | 'P' 'p' 'A' |
| BOOLEAN | only 2 values (result of a comparison) | TRUE FALSE |
Give the data type for: Mark = 60 · Subject = "Computer Science" · Grade = 'B' · CourseCompleted = TRUE · AverageMark = 49.5
5 / 5
2. Data Identifier Table
Definition: a table that lists the variables a program uses. (LOV = List Of Variables)
| LOV (identifier) | Description | Datatype |
|---|---|---|
| ProjectCompleted | tells the status of the project (True or False) | BOOLEAN |
3. Algorithm, Source Code, Object Code…
Algorithm: a sequence of steps / instructions to implement a task / a solution to a problem. (anything can have one — washing a car, studying!)
Stages of an algorithm (IPO)
| Term | Meaning |
|---|---|
| Source code | a solution / design / algorithm expressed in a high-level language |
| Object code | produced by the compiler during the translation stage, by translating the source code. NOT produced by an interpreter. |
| Pseudocode | using keywords and identifiers to describe an algorithm without following the syntax of a particular programming language |
| Flowchart | pictorial / graphical representation of a program in a flow |
Features that make a program easier to read & understand
- Indentation
- Blank lines (white space)
- Capitalisation of keywords
- Sensible (meaningful) variable names
- Comments
- Pretty print
4. Four Basic Constructs (building blocks of programming)
| Construct | Meaning | Example / keywords |
|---|---|---|
| ① Assignment | a value is given a name (identifier) or the value of an identifier is changed | Flag = True Number = 5 → Number = Number − 1 → Number = 4 |
| ② Sequence | steps performed one after the other | statements run top → bottom |
| ③ Selection | under certain conditions some steps are performed, otherwise none / different steps | IF … THEN … ELSE … ENDIF CASE OF … OTHERWISE … ENDCASE |
| ④ Repetition / Iteration | steps performed a number of times (= looping) | FOR…TO…NEXT (count-controlled) WHILE…DO…ENDWHILE (pre-condition) REPEAT…UNTIL (post-condition) |
Tick Selection / Repetition / Assignment for each statement:
6 / 6
5. Identifiers: Constant · Variable · Array
| Constant | Variable | Array |
|---|---|---|
| fixed, not changeable value cannot be changed accidentally during execution |
temporary memory stores a value that can change during execution |
temporary memory list of items of the same data type under a single name |
6. Verification vs Validation
Verification
Checking data has not changed during transfer / input to a computer. (same data arrived)
- Double entry
- Parity check
- Checksum
Validation
Checking data meets certain criteria (is sensible). It does not prove data is correct.
- Range check
- Presence check
- Length check
- Format check
- Character check
- Type check
Scenario e.g. "under-18s must sit in this class" ⇒ range check. Names can't be range-checked — only numbers / dates.
7. Types of Test Data (example: accepted range 5 ≤ x ≤ 10)
| Type | Meaning | Example |
|---|---|---|
| ① Normal | within range (accepted) | 5 ≤ x ≤ 10 → 7 |
| ② Abnormal | out of range (rejected) | −2, 12, 14 |
| ③ Extreme | in range — the largest and smallest accepted value | 5 and 10 |
| ④ Boundary | at the edge: one accepted + one rejected pair | 5, 10 accepted · 4, 11 rejected |
8. Features of a Program & the IDE
Features of a program: function / procedure · sequence ✓ · iteration ✓ · selection ✓ · parameters · variable ✓ · logic operation (mark schemes vary; input/output & comparison operators can also appear — write extra if unsure).
IDE (Integrated Development Environment): a software application that combines all the features and tools needed by a software developer.
Features of an IDE
- Pretty print ✓
- Automatic indentation ✓
- Syntax checking ✓
- Highlights any undeclared variable ✓
- Type checking
Help in "initial error detection"
- Dynamic syntax checking
- Type checking
- Identification of unused variables
- Dry run / trace table
- Breakpoint — run the code up to a set point to find the error
- Variable watch (report window) — checks the content of variables at specific points
- Stepping — execute the code line by line
Function Calculate() returns an unexpected value. Describe how an IDE helps find the error.
1 mark for each underlined term + 1 mark for explaining it (max 4).
term + explanation × 2 = 4
9. Program Development Cycle
6 stages (books)
- Problem solving
- Design
- Coding
- Translating
- Execution
- Testing
5 stages ✓ (your mark scheme!)
- Analysis
- Design
- Coding
- Testing
- Maintenance
| Tool | What it does |
|---|---|
| Editor | produces the source code in a high-level language |
| Translator | converts source code into object code |
| Debugger | used to test the program / detect errors |
10. Development Models
Three models: Waterfall · Iterative · Rapid Application Development (RAD).
① Waterfall model
| Benefit | Drawback |
|---|---|
| • easy to manage, understand and use • stages don't overlap — completed one at a time • works well for smaller programs |
• difficult to change requirements at a later stage • not suitable if the program is subject to change • working program produced late in the life cycle • not suitable for complex projects |
② Iterative model
| Benefit | Drawback |
|---|---|
| • easier to test and debug • more flexible — easier to alter requirements • customer involved each iteration ⇒ no surprises at the end |
• whole system needs to be defined at the start • needs good planning overall and at every stage • not suitable for short, simple projects |
③ Rapid Application Development (RAD)
| Benefit | Drawback |
|---|---|
| • reduced overall development time • rapid feedback informs the development • very flexible — requirements evolve from feedback • modification easier because each part must work independently |
• system under development needs to be modular • needs a strong team of skilled developers • not suitable for short, simple projects |
Games-console website; requirements likely to change as more info about the console appears. A company chose waterfall.
11. Transferable Skills
Definition: skills a person has in one language that can be used in another language.
You should be able to recognise / understand in another language: declaration · assignment · sequence · selection · repetition / iteration · subroutines · parameters passed between modules · input / output (also variables, logic operations, comparison operators).
An algorithm is implemented in a high-level language and given to Albert, an experienced programmer unfamiliar with that language. Explain why Albert can still understand the program.
12. Types of Maintenance (of a program — so it keeps running correctly)
| Type | Meaning | Reason / key words |
|---|---|---|
| Corrective | occurs when testing reveals a fault / error — it is found and fixed | to amend the algorithm to eliminate errors |
| Perfective | implements new or changed user requirements; functional enhancement — improves function and efficiency of the code | "improve speed of response" ⇒ perfective |
| Adaptive | changes made in response to specification changes — changed requirements or available technology | changes to business rules or environment |
| Preventive | activities to prevent the occurrence of errors | — |
13. Types of Error
| Error | Meaning | Example |
|---|---|---|
| Syntax | small grammatical mistakes, sometimes a single character — program won't compile / run | missing semi-colon at end of a line; extra bracket at end of a function; "This is basketball very new" |
| Logic | program runs but does not perform as expected — error in the logic | wrong formula / wrong comparison; AVERAGE displayed wrongly |
| Run-time | program executes an invalid instruction and crashes | out-of-bounds array index; divide by zero |
14. Software Testing
| Test | Key points |
|---|---|
| Black-box | match expected answer to actual answer (e.g. 5 + 3 → expect 8, got 8 ✓) · tester does not need to know the code structure · chooses normal, boundary and erroneous data |
| White-box | test every possible logic path through the code · a trace table is often used |
| Alpha | in-house testing — done by other developers in the software house (not the one who built it) |
| Beta | out-of-house testing — a group of people assigned to find bugs; real users before release |
| Stub | a simple / dummy module written to stand in for a module that is missing or faulty so testing can continue |
| Integration | testing separately written modules to ensure they work together |
| Acceptance | on the completed program, to prove to the customer / client it works as required · end-user testing |
15. Stepwise Refinement & Subroutines
Stepwise refinement: breaking down an algorithm, to a level of sufficient detail, into smaller parts, from which it can be programmed.
Note: each sub-task can be a module refined separately. A module / subroutine is either a function or a procedure.
| Procedure | Function |
|---|---|
| sequence of steps with an identifier, called to perform a sub-task — does NOT return a value | same, but RETURNS a value |
Uses of a subroutine
- perform a frequently used operation within a program
- can be called when needed
- can be reused by another program
Why use modules?
- more manageable / understandable solution
- module can be tested independently
- program easier to maintain
Passing parameters between modules
Values passed between modules are called parameters. Board example: Module A passes x to Module C; Module C passes z back to Module B — so x and z are parameters.
| By value | By reference |
|---|---|
| a copy of the variable is passed — original value is NOT changed | the address of the variable is passed — original value IS changed |
16. More Past-Paper Questions (with answers)
Expression 4 in simplest form: NOT Exempt (Active OR NOT Active is always TRUE)
Customer: Name (String), Number of points (Integer), Date of birth (Date).
(b) Stepwise refinement into 5 steps (bands: <$10 → 5 pts/$ · $10–$100 → 7 pts/$ · >$100 → 10 pts/$; e.g. $99.77 → band 2 → 7 × 99 = 693):
- use constants / variables for the thresholds 10 and 100; input amount spent
- work out which band the amount is in
- work out the rounded (whole-dollar) part of the amount
- points = rounded amount × points-per-dollar of the band
- output the number of points
10 DECLARE Sheet4 : ARRAY[1:2, 1:50] OF INTEGER … 100 FOR PCount ← 0 TO 49 … Sheet4[1, PCount] ← 0 · Sheet4[2, PCount] ← 47 … 103 NEXT PCount
Make a complex statement ignored by the compiler without deleting it → change it into a comment (or into a string literal assigned/output).
- Types: INTEGER (no dp) · REAL (dp) · STRING " " · CHAR ' ' · BOOLEAN
- 4 constructs: assignment · sequence · selection · iteration (FOR / WHILE pre / REPEAT post)
- Validation = sensible (range, presence, length, format, character, type) · Verification = not changed (double entry, parity, checksum)
- Test data: normal · abnormal · extreme · boundary
- 5 stages: analysis · design · coding · testing · maintenance — Waterfall / Iterative / RAD
- Maintenance: corrective · perfective · adaptive · preventive
- Errors: syntax · logic · run-time — Tests: black · white · alpha · beta · stub · integration · acceptance
- Procedure = no return · Function = returns · By value = copy · By reference = address (original changes)