10.2 Thinking Ahead Flashcards
What is the ‘input’ in an abstract model?
The information relevant to the problem, which could for example be passed as parameters to a subroutine
What is the ‘output’ in an abstract model?
The solution to the problem, which could be passed back from a subroutine
Why is it important to think ahead?
Because the algorithm you are working on must be correct and it also must be efficient
Advantages of documenting the inputs and outputs?
There is no ambiguity in what must be supplied to the sub-procedure and what is returned
Advantages of specifying preconditions
- Makes program components reusable
- Cutting out unnecessary checks
- Makes programs easier to debug and maintain
What are some examples of reusable program concepts?
Libraries and components
List some typical standards for reusable modules
- Inputs, outputs and preconditions should be documented
- Variable identifiers should conform to a standard convention
Cashing
Temporary storage of data and instructions
Advantages of caching
- Faster access to cached resources
- Saving on costly use of bandwidth
- Reduced load on web services in a client-server environment
Drawbacks of caching
- Slower performance if the resource isn’t found in the cache
- Could be given a stale copy of a resource when an up-to-date copy is needed