ICDL Coding Principles study materials
ICDL Coding Principles study resources

ICDL Coding Principles (ICDL): Coding Principles: Structure, Readability and Correctness

ICDL Coding Principles · Work through your exam, one topic at a time.

All guide sections

Coding Principles: Structure, Readability and Correctness

What this domain covers

Coding principles are the habits that make a program understandable, maintainable and dependable, independent of any particular language. A candidate should be able to name and apply: naming conventions (descriptive identifiers, consistent case style), indentation and layout (block structure made visible), comments (explaining why, not restating what), modularity (small single-purpose functions, parameters instead of hidden globals), constants over magic numbers, defensive input handling (validation, range checks), and avoiding duplicated logic (the DRY idea). You should also recognise the difference between a syntax error (the code cannot be parsed), a runtime error (it parses but fails while executing, e.g. division by zero or an out-of-range index), and a logic error (it runs and produces a wrong answer).

Traps to watch for

Questions often reward the most specific answer. "Add a comment" is weaker than "rename the variable so the comment becomes unnecessary". A loop that runs one time too many or too few is a classic off-by-one logic error, not a syntax error. Copy-pasting a block and editing one copy is a maintenance defect even though the output is correct. Also beware of questions that confuse testing (finding defects) with debugging (locating and fixing them).

Rule of thumb

Ask of any snippet: Could another programmer change this safely without asking me? If a value is repeated, name it; if a function does two jobs, split it; if input is unchecked, guard it.

Worked example

total = price * 1.175 - the rate is a magic number. Better: TAX_RATE = 0.175 then total = price * (1 + TAX_RATE). The intent is now readable and the rate changes in one place.