How do you develop, read, refine and debug a program, and write readable code?
Use decomposition and abstraction to solve problems; read, write, analyse and refine programs; convert algorithms (flowcharts, pseudocode) into programs; use techniques (layout, indentation, comments, meaningful identifiers, white space) for readable code; identify, locate and correct logic, syntax and runtime errors; and evaluate a program's fitness for purpose and efficiency.
A focused answer to Edexcel GCSE Computer Science 6.1, covering using decomposition and abstraction in programs, converting algorithms to code, writing readable code, identifying and correcting errors, and evaluating fitness for purpose.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
Edexcel wants you to develop programs well: use decomposition and abstraction, turn algorithms into code, write readable, maintainable code, find and fix errors (logic, syntax, runtime), and evaluate a program's fitness for purpose and efficiency. This underpins the whole of Paper 2, which is written in Python 3.
From problem to program
This is the same computational thinking from Topic 1, now applied to writing real code. A decomposed design means you can write and test one subprogram at a time. Converting an algorithm to code is a direct translation: a "repeat 10 times" step becomes a for loop, an "if the score is high" step becomes an if statement, and so on. Doing the design first makes the coding faster and the result clearer.
Writing readable, maintainable code
These techniques matter because programs are read far more often than they are written, by other people and by you months later. Meaningful identifiers make code self-explanatory; comments explain anything non-obvious; indentation and white space reveal the structure at a glance. In Python, indentation is not optional, it defines which statements are inside a loop or if, so getting it right is essential to both correctness and readability.
# Calculate the average of a list of marks
total = 0
for mark in marks:
total = total + mark
average = total / len(marks)
print(average)
The comment, clear names (total, average, marks) and indentation make this easy to follow.
Finding and fixing errors
You locate errors differently by type. Syntax errors are reported by the interpreter, which usually points to the line, so they are quick to fix. Runtime errors appear for certain inputs and produce an error message at the point of failure, so you test with a range of data to trigger them. Logic errors are the hardest because the program runs without complaint, so you use a trace table and test data with known expected results to find where the output goes wrong, then correct the algorithm.
Evaluating a program
Evaluation is what turns working code into good code. Testing with normal, boundary and erroneous data checks fitness for purpose; thinking about how many comparisons or loop passes the program makes, and how much memory it uses, checks efficiency. Refining then acts on what you find, fixing faults, tidying the code, or making it more efficient.
Try this
Q1. State the type of error caused by a missing colon at the end of a Python if statement. [1 mark]
- Cue. A syntax error.
Q2. State one technique that makes code easier to read. [1 mark]
- Cue. Any one of: meaningful identifiers; comments; indentation; white space; sensible layout.
Exam-style practice questions
Practice questions written in the style of Pearson Edexcel exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
Edexcel 20224 marksA program contains the line below, which should print whether a number is positive. Identify the error, state its type, and write the corrected line.
if number > 0
print('positive')Show worked answer →
The error is a missing colon at the end of the if statement; in Python an if line must end with a colon.
This is a syntax error, because it breaks the rules of the language, so the program will not run.
The corrected line is:
if number > 0:
print('positive')
Markers reward identifying the missing colon, classifying it as a syntax error (breaks the language rules so it will not run), and giving the corrected code with the colon.
Edexcel 20214 marksDescribe two techniques a programmer can use to make a program easier to read and maintain, and explain why each helps.Show worked answer →
Choose two techniques and explain the benefit.
Meaningful identifiers: giving variables and subprograms descriptive names (such as total_score rather than t) makes the code self-explanatory, so a reader can understand what each part does without extra effort.
Comments: adding notes that explain what a section of code does or why, which helps another programmer (or the same one later) understand and safely change the code.
(Indentation and white space, which show the structure and group related code, are alternatives.)
Markers reward two techniques (meaningful identifiers, comments, indentation, white space, sensible layout) each with a developed reason about readability or maintainability.
Related dot points
- Identify the structural components of programs (constants, variables, initialisation, assignment, sequence, selection, repetition, iteration, data structures, subprograms, parameters, input/output) and write programs that use sequencing, selection, repetition (count-controlled, condition-controlled) and iteration with single entry and exit points.
A focused answer to Edexcel GCSE Computer Science 6.2, covering the structural components of programs and writing Python programs that use sequence, selection, count-controlled and condition-controlled repetition, and iteration.
- Write programs that make appropriate use of primitive data types (integer, real, Boolean, char) and one- and two-dimensional structured data types (string, array, record), and that make appropriate use of variables and constants.
A focused answer to Edexcel GCSE Computer Science 6.3.1 and 6.3.2, covering the primitive data types (integer, real, Boolean, char), structured types (string, array, record) in one and two dimensions, and using variables and constants.
- Write programs that manipulate strings (length, position, substrings, case conversion).
A focused answer to Edexcel GCSE Computer Science 6.3.3, covering string manipulation in Python: finding length, accessing characters by position, extracting substrings, and converting case.
- Write programs that use pre-existing and user-devised subprograms (procedures, functions), write functions that return values and procedures that do not, with or without parameters, use the arithmetic, relational and logical operators, and use global and local variables appropriately.
A focused answer to Edexcel GCSE Computer Science 6.5 and 6.6, covering functions and procedures, parameters and return values, built-in and user-defined subprograms, the operators, and global versus local variables in Python.
- Understand syntax, logic and runtime errors and correct logic errors in algorithms; understand how the standard algorithms (bubble sort, merge sort, linear search, binary search) work; and use logical reasoning and test data to evaluate an algorithm's fitness for purpose and efficiency.
A focused answer to Edexcel GCSE Computer Science 1.2.5, 1.2.6 and 1.2.7, covering syntax, logic and runtime errors, the bubble sort, merge sort, linear search and binary search, and evaluating an algorithm's efficiency.
Sources & how we know this
- Pearson Edexcel GCSE (9-1) Computer Science (1CP2) specification — Pearson (2020)
- Pearson Edexcel GCSE Computer Science Programming Language Subset (Python) — Pearson (2020)