2.1.2 Thinking Ahead

Cards (9)

  • Thinking Ahead
    planning inputs and outputs.
    • what answers do we need?
    • how can we turn the inputs into required outputs?
    • what do we need to know?
  • Identifying inputs and outputs
  • Preconditions
    Requirements which must be met before a program can run
  • Caching
    • process of storing instructions or values in cache memory after they have been used, as they may be used again
    • saves time which would have been needed to store and retrieve the instructions from secondary storage again.
    • content can be loaded without any delay. This also means images and text do not have to be downloaded again multiple times, freeing up bandwidth for other tasks on a network
  • Prefetching
    • Loading a resource before it is needed
    • algorithms predict which instructions are likely to soon be fetched
    • less time is spent waiting for instructions to be loaded into RAM from the hard disk
  • Limitations of Prefetching
    • accuracy of the algorithms used in prefetching, only provide an informed prediction and there is no guarantee that this will be right
    • cache size limits how much data can be stored
  • Reusable Program Components
    • Commonly used functions are often packaged into libraries for reuse
    • include: implementations of abstract data structures such as queues and stacks as well as classes and subroutines.
  • Pros of Reusable Program Components
    • save time for programmer
    • save on development costs for project
    • Reliable and bug free
    • optimised by experts
  • Example of reusable program components
    In a game there will be pre-written code for:
    • high score table
    • movement control
    • rendering of images
    • timer routines