Save
Computer science OCR A Level
2.1.2 Thinking Ahead
Save
Share
Learn
Content
Leaderboard
Learn
Created by
Aanya Sinha
Visit profile
Cards (16)
Inputs and Outputs
Designing a
solution
requires thinking ahead about how the different
components
of a problem can be handled in the best possible way
Developers can build programs that are
easy
and
intuitive
to use
Inputs
Data required to solve the problem, entered into the
system
by the
user
Outputs
Results that are
passed
back, the
solution
to the problem
All
computational
problems consist of
inputs
which are processed to produce an output
Evaluating inputs and outputs
Consider data
structures
and data
types
involved
Consider
input
and
output
devices
Designing a solution
1. Consider the
outputs
based on the user's
requirements
2. Identify the
inputs
required and how these need to be processed to achieve these
outputs
Preconditions
Requirements which must be
met before
a
program
can be executed
Preconditions
Can be tested for
within
the
code
Included in the documentation accompanying a particular
subroutine
,
library
or program
Specifying preconditions
Expects the
arguments
passed to it to meet certain criteria
Reduces the
length
and
complexity
of the program
Saves time spent on
debugging
and
maintenance
Makes subroutines more
reusable
Reusable program components
Commonly used functions packaged into
libraries
for
reuse
Reusable components
Abstract
data structures (e.g. queues and stacks)
Classes
Subroutines
(e.g. functions and procedures)
Reusing program components
Problem
decomposition
is used to identify where
previously-developed
program components can be reused
More
reliable
than newly-coded components, as they have already been
tested
Save
time
,
money
and resources
May need to be modified to be
compatible
with existing
software
Caching
Storing
instructions
or values in cache
memory
after they have been used, as they may be used again
Benefits of caching
Saves time of
retrieving instructions
from
secondary
storage again
Frees up bandwidth
for other tasks on a network
Prefetching
Algorithms predict which
instructions
are likely to soon be fetched and are loaded and stored in
cache
Drawbacks of caching
Limited by
accuracy
of algorithms used, as
data stored
in cache is not always used
Effectiveness depends on
caching
algorithm's ability to
manage
the cache
Larger caches take a
long time
to
search
, but smaller cache sizes limit how much data can be stored
Can be
difficult
to implement well