ICDL Coding Principles (ICDL) cheat sheet
ICDL Coding Principles · Keep the key ideas within reach.
Computational Thinking and Problem Solving
Decomposition splits a problem into sub-problems that can be solved, tested and understood independently, then combined.
Abstraction removes detail irrelevant to the solution, keeping only the features the model needs.
Pattern recognition identifies similarities between problems so one solution or routine can be reused.
An algorithm is a finite, ordered set of unambiguous steps that takes input, produces output and terminates.
Algorithm properties to check: finiteness (it ends), definiteness (each step is precise), input, output, effectiveness.
Pseudocode is language-independent and has no fixed syntax; it uses structured English plus keywords such as IF, WHILE, FOR.
Flowchart symbols: oval = start/end, parallelogram = input/output, rectangle = process, diamond = decision, arrow = flow direction.
Linear search scans items one by one and works on unsorted data, up to n comparisons; binary search needs sorted data and takes about log2(n) comparisons.
Problem-solving cycle: analyse the problem, design an algorithm, implement it, test it, refine it.
Coding Concepts and Program Structure
Three control structures: sequence, selection, iteration; any algorithm can be expressed with these alone.
Sequence executes statements top to bottom in written order with no branching or repetition.
Selection: if runs a block when the condition is true; if-else adds an alternative branch; case/switch selects among many branches.
Iteration: for loops are definite (count known in advance); while loops are indefinite (condition tested before each pass); do-while tests after the body, so the body runs at least once.
A function returns a value; a procedure performs an action without returning a value.
Arguments are the values supplied at the call; parameters are the names in the definition that receive them.
A compiler translates the whole source into machine code before execution; an interpreter translates and executes line by line.
A loop whose condition never becomes false is an infinite loop; the loop control variable must be updated inside the body.
Modularity: short, single-purpose subprograms are easier to test and reuse; data passes between modules through parameters and return values.
Data, Variables and Control Flow
A variable is a named memory location whose value can change during execution; a constant is assigned once and cannot change.
Core data types: integer, real/float, character, string, Boolean.
Boolean operator precedence: NOT first, then AND, then OR; brackets override precedence.
Arithmetic precedence: brackets, then exponent, then * / DIV MOD, then + and -, left to right within a level.
DIV returns the integer quotient and MOD returns the remainder: 17 DIV 5 = 3 and 17 MOD 5 = 2.
Comparison operators (=, <>, <, >, <=, >=) return a Boolean value used by selection and iteration.
String concatenation joins strings end to end: "ab" + "cd" gives "abcd".
Array/list indexing usually starts at 0, so the last element of an n-item list is at index n-1; an out-of-range index is a runtime error.
Scope rule: a local variable exists only inside its block; a global variable is visible throughout the program.
Testing
A test case consists of input data, the expected output and the reason that case was chosen.
Black-box testing uses only inputs and outputs; white-box testing uses knowledge of the internal statements, branches and paths.
Test data categories: normal (typical valid), boundary/extreme (edges of the valid range) and erroneous (invalid data that must be rejected).
Boundary testing checks the minimum, the maximum and one step beyond each end of every valid range.
A dry run fills a trace table with one row per statement and one column per variable to show how values change.
Unit testing targets one component in isolation; integration testing targets combined components; regression testing re-runs earlier tests after a change.
Testing can show the presence of errors but never their absence, because exhaustive testing of all inputs is impossible.
A test plan records the cases to run, the order of running and the expected result for each case.
Debugging and Documentation
Error types: syntax (breaks grammar, prevents compilation), logic (runs but gives wrong output), runtime (fails during execution).
Debugging sequence: reproduce the fault, isolate the faulty section, diagnose the cause, fix it, then re-test both the fix and surrounding code.
A breakpoint pauses execution at a chosen line; stepping executes one statement at a time; a watch displays a chosen variable's current value.
A trace table locates logic errors by recording each variable's value after every executed step.
Internal documentation lives inside the source file: comments, meaningful identifier names, indentation and consistent formatting.
External documentation lives outside the source file: user guide, installation guide and technical reference.
Comments should explain why code does something rather than restate what it does, and must be updated whenever the code changes.
Maintenance types: corrective (fix faults), adaptive (new hardware or software environment), perfective (improve performance or features), preventive (reduce future risk).