Revise Computingrevisecomputing.co.uk
Free student revisionSee questionsFor schoolsSchool enquiry
Free revisionSee questionsFor schoolsSchool enquiry
Knowledge/A Level/H446/02 Algorithms and programming/Thinking ahead/The need for reusable program components

The need for reusable program components

The need for reusable program components.

2.1.2 Thinking ahead

Thinking ahead — Note 4 of 4

Candidates need to understand why reusable program components (such as subroutines, classes and libraries) are needed. Candidates should understand the benefits of reuse, such as reduced development and testing time, and identify where components could be reused in a solution.

What you need to know

Reusable program components are pieces of code, such as subroutines, classes and libraries, that can be used in more than one place or more than one program. Planning for reuse saves time and improves reliability.

What to know

  • Benefits: saves development time; components have already been tested, so they are more reliable; consistent behaviour across programs; easier maintenance because a fix is made in one place.
  • Drawbacks: a component may need adapting to fit a new problem; making code general can take longer initially; compatibility issues with different versions.
  • Good reusable components have clear inputs (parameters), outputs (return values) and documented preconditions, and do not rely on global variables.

Key terms

Exam tipCommon mistake

Reusable component

A self-contained piece of code (e.g. a subroutine, class or library module) designed so it can be used in different parts of a program or in other programs.

  • Exam tip: When identifying reusable components in a scenario, pick tasks that are repeated or common to many programs, e.g. validating input or sorting a list.
← Previous noteThe nature, benefits and drawbacks of caching2.1.2 Thinking aheadNext topic →Identify the components of a problem2.1.3 Thinking Procedurally

Back to Thinking ahead

Thinking ahead

Note 4 of 4

  1. 1Identify the inputs and outputs for a given situation
  2. 2Determine the preconditions for devising a solution to a problem
  3. 3The nature, benefits and drawbacks of caching
  4. 4The need for reusable program components
Topic overview