OCR GCSE Computer Science (J277) · Paper 2
⌨️ Programming
Revision notes written to the specification, with examiner tips and the required practicals. Every point here has flashcards in the Stickwise app.
Fundamentals & data structures
Three constructs build every program: sequence, selection (if/elif/else) and iteration, where a for loop is count-controlled and a while loop is condition-controlled. Values are stored in variables or constants, typed as integer, real, Boolean, character or string. Because keyboard input always arrives as a string, any maths on it needs casting first, for example int(input()). Random numbers, generated with something like random(1,6), power dice rolls, shuffles and simulations.
Robust programs & testing
Defensive design means assuming things will go wrong. Validation checks the data itself: its presence, type, range, format and length. Authentication checks the person, through passwords with lockouts, 2FA and biometrics. Good design anticipates misuse, such as dividing by zero, typing 'banana' where a number is expected, leaving inputs empty, or mashing buttons, and handles all of it with polite error messages rather than crashing. Maintainability comes from comments, sensible indentation, honest variable names and sub programs, since code is really a letter written to the next programmer.
A syntax error breaks the rules of the language and stops the program running at all, whereas a logic error lets the program run but gives the wrong answer. Testing should happen iteratively while the program is being built, and terminally once it is finished, using normal, boundary, invalid and erroneous data, since programs tend to fail at the edges and on the inputs nobody expected.
Boolean logic, languages & IDEs
Read a logic circuit left to right, bracketing each gate in turn: if A and B feed into an AND gate, and the result is joined with C at an OR gate, the expression is P = (A AND B) OR C, with the brackets showing which gate fires first. High-level languages are English-like and portable but need translating, while low-level languages, such as assembly and machine code, are the CPU's own language. A compiler translates the whole program at once, giving a fast final product and a full list of errors, and can be distributed on its own; an interpreter translates line by line, starting instantly but halting at the first error, which makes it well suited to learning. An IDE bundles together a smart editor, a run-time environment, error diagnostics and breakpoints.