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 about inputs and outputs when thinking ahead?
Identify the inputs and outputs that are likely to be used in a book reservation system i.e. at a library
Inputs:
Outputs:
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:
Factorial function:
- The number passed to the function cannot be negative
State 2 advantages of including preconditions within the documentation accompanying a subroutine
Define caching
The process of storing instructions or values in cache memory after they have been used, as they may not 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 delay
What are the disadvantages of caching web pages?
What is the name given to the technique in which algorithms are used to predict which instructions are likely to soon be used?
Prefetching
What are some advantages of caching?
Give a limitation of caching
Give 3 advantages of using reusable program components
Give 2 examples of reusable program components