Validation, Verification and High-Level Languages
Data Quality in Programs
A program is only as good as the data it processes. If a user accidentally types their age as 300, or pastes an email address into a phone number field, the program can produce meaningless output or crash entirely. Two techniques guard against bad data: validation and verification. Students often confuse these two — understanding the distinction is worth marks every exam series.
Validation checks that data is sensible — within expected bounds, correct format, the right type. A program does this automatically. Verification checks that data was entered correctly — that what the user typed matches what they intended. A human or a double-entry system does this.
Types of Validation Check
There are six main validation checks you need to know. Each one catches a different kind of invalid data:
| Validation check | What it tests | Example |
|---|---|---|
| Range check | Value falls within an allowed minimum and maximum | Age must be between 0 and 120 |
| Type check | Data is of the correct data type | Phone number field must contain only digits |
| Presence check | A required field has not been left blank | Name field must not be empty |
| Length check | Input is not too short or too long | Password must be 8–20 characters |
| Format check | Input matches a required pattern or structure | Postcode must match the pattern XX00 0XX |
| Check digit | A calculated digit confirms the rest of the number is correct | ISBNs and barcodes use check digits |
Below is a pseudocode routine that validates a student’s percentage score. It combines a type check (implicit in reading the score as an integer) and a range check:
INPUT score
WHILE score < 0 OR score > 100
OUTPUT “Score must be between 0 and 100. Try again.”
INPUT score
END WHILE
OUTPUT “Score accepted: ” & score
The WHILE loop keeps prompting until the score is valid. A single IF would only check once and could still accept invalid data on a subsequent entry.
Verification
Verification is about catching transcription errors — mistakes made while copying or typing data. A validated age of 23 might still be wrong if the user meant to type 32. There are two common verification techniques:
Double entry: The user types the same data twice. The program compares both entries and only accepts them if they match. This is common for passwords and email addresses on registration forms.
Proofreading: A human reads through entered data to check for errors. This is used in contexts where computer checking is impractical, such as checking a handwritten address against a database record.
Validation cannot catch all errors. If a student’s real age is 15 but they type 16, a range check (0–120) accepts 16 because it is within range and the correct type. Validation can only reject data that is clearly outside the rules — not data that is plausible but incorrect. Verification addresses this gap.
High-Level and Low-Level Languages
Every program written in a language such as Python must eventually be translated into the binary instructions that the processor understands. The level of a programming language describes how close it is to human language versus machine language.
A high-level language (such as Python, Java or C++) is designed to be readable by people. It hides the underlying hardware detail — you do not need to know how the processor registers work to write a Python loop. High-level languages are portable: the same Python code can run on Windows, macOS and Linux with little or no modification.
A low-level language is closer to the hardware. Assembly language uses short mnemonic codes (like MOV, ADD, JMP) for individual processor instructions. Machine code is the raw binary (0s and 1s) that the processor executes directly. Low-level languages give the programmer direct control over memory and processor behaviour — useful for device drivers, operating systems and embedded systems — but they are harder to write and not portable between different processor architectures.
The table below summarises the key differences:
| Feature | High-level language | Low-level language |
|---|---|---|
| Readability | Easy — resembles English | Hard — cryptic mnemonics or binary |
| Portability | Runs on many platforms with little change | Tied to a specific processor architecture |
| Control over hardware | Abstract — hardware details are hidden | Direct control over memory and registers |
| Translation needed | Yes (compiler or interpreter) | Assembler for assembly language; machine code is already binary |
| Typical use | Web apps, data processing, games | Device drivers, OS kernels, embedded systems |
To run on a processor, every high-level program must be translated. A compiler translates the whole program at once; an interpreter translates and runs it line by line. An assembler translates assembly language into machine code. These translators are covered in detail in the next lesson.