ProceduralOCR J277
DashboardCoursePracticeReviewProgressGlossary
Saved on this deviceContinue learning

Procedural · OCR J277 programming practice

Progress stays in this browser unless you export it.

Course/Robust programs/Decomposition and complete solutions
J277 · 2.1.1, 2.2.1, 2.2.3, 2.3.1

Unit 10 · Lesson 8

Decomposition and complete solutions

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Decompose a problem and write a complete procedural solution using sequence, selection, iteration, functions and validation.

A complete solution becomes manageable when it is decomposed. First identify inputs, processes and outputs. Then name small tasks such as getValidatedCount, calculatePrice and displayResult. Each sub-program should have clear parameters and return values, while the main program coordinates them. The final solution can combine sequence for ordered steps, selection for decisions and iteration for repetition. Meaningful names, constants, comments, indentation and reusable sub-programs also make it easier to maintain.

Decomposition

Breaking a problem into smaller manageable parts that can be solved individually.

Algorithmic thinking

Identifying the required steps and the sequence in which they must be completed.

Main program

The controlling part that gathers data and calls the required sub-programs.

Procedural solution

A complete program organised as ordered instructions and reusable sub-programs.

Maintainability

How easy a program is to understand, update and fix after it has been written.

Keep these in mind

  • Apply decomposition to the scenario rather than only repeating its definition.
  • Identify inputs, processes and outputs before coding.
  • Give each sub-program one clear responsibility.
  • Pass data through parameters and returned values instead of unnecessary globals.
  • Initialise counters and accumulators before their loops.
  • Test normal, boundary and invalid paths through the complete program.
  • Improve maintainability with meaningful names, useful comments, constants and reusable sub-programs.

Learning objective

Decompose a problem and write a complete procedural solution using sequence, selection, iteration, functions and validation.

Exam tip

For a long Write question, annotate input, validation, processing and output, then build and call small sub-programs. A complete answer needs the calls as well as the definitions.

Common mistake

Do not reset a total inside its loop, omit a function call or print inside a function that the main program needs to reuse. Check the complete data flow from input to final output.

Previous