Save
computer science
2.1.2: thinking ahead
Save
Share
Learn
Content
Leaderboard
Learn
Created by
Fiona Bull
Visit profile
Cards (16)
What is the purpose of thinking ahead?
To make programs
easy
and
intuitive
for users to use.
Define
inputs.
Any data that is required to solve a problem, usually entered into the
system
by the
user.
Define outputs.
The results that are passed back once the inputs have been processed and the problem solved.
What three considerations do programmers need to make about inputs and outputs when thinking ahead?
Method
of input/output (device used)
Data
structures used
Data
types used
Order of
data
Identify the inputs and outputs that are likely to be used in a book reservation system i.e. at a library.
inputs
:
book
details
: name, author
ISBN
borrower
details
, name,
library
card number
collection point
outputs
:
expected
waited time
confirmation
availability
at other libraries
What are
preconditions
?
Requirements which must be
met before
a
program
can be executed.
Where can preconditions be defined?
Within the
code
or within
documentation
Give an example where preconditions are required.
Stack functions
:
Check that a
stack
is not empty when popping an element from a
stack
Check that a
stack
is not full when pushing an element onto a
stack
factorial function
The number passed to the function cannot be negative
State two advantages of including preconditions within the documentation accompanying a subroutine.
Reduces
the
length
of the program
Reduces the
complexity
of the program
Saves time
needed to debug and maintain a
longer
program
Makes subroutine more
reusable
Define
caching
The process of storing
instructions
or values in cache
memory
after they have been used, as they may be used again.
How is caching used in storing web pages?
Web pages that a user frequently accesses are
cached
, so the next time one of these pages is accessed, content can be loaded without any
delay.
What are the advantages of caching web pages?
Content
can be loaded without delay
Images
and
text
do not have to be downloaded again multiple times
Frees
bandwidth for other tasks on a network
Less time is spent
waiting
What is the name given to the technique in which algorithms are used to predict which instructions are likely to soon be used?
Prefetching
Give a limitation of caching
Accuracy
of the algorithms used
Effectiveness
of algorithm in managing the cache
Size
of the cache
Give three advantages of using reusable program components.
More
reliable
than
new components
, as they have already been tested.
As
developing
from
scratch
is not required, this saves time, money and resources.
Give two examples of reusable program components.
Abstract data structures
eg. queues and stacks
Classes
Subroutines