2.1.2 thinking ahead Flashcards
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 3 considerations do programmers need to make regarding inputs and outputs when thinking ahead?
method of input/output, data structures used, data types used, order of data
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 and factorial functions
state 2 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 in 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 spend waiting
what is the name given to the technique in which instructions are fetched based on algorithms which 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 3 advantages of suing 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 2 examples of reusable program components
abstract data structures, classes, subroutines