2.1.2 - Thinking ahead Flashcards
What is the first step in constructing a solution to a computational problem?
Identifying the inputs and outputs
What is a precondition?
A condition that is specified within the documentation of a subroutine.
A condition check that should be ran before the subroutine is called.
Advantages of preconditions
Specifying beforehand within the documentation allows the user to know what checks, if any, must be carried out before the subroutine is called.
If there are no preconditions then the user knows that all checks will be handled by the subroutine itself. This can save necessary coding - the shorter the program the easier it will be to debug and maintain.
Clear documentation of the inputs, outputs and preconditions helps to make the subroutine reusable.
What is the need for reusable program concepts? State an example.
Having components that have been thoroughly debugged and tested that are already written will save time in completing a project and make the project more manageable.
EG Windows DLL (Dynamic-link library) OR Programmers creating custom libraries for abstract data structures which may be used in many different modules and can be contained and managed within one whole reusable library.
What is caching?
Caching is the temporary storage of program instructions or data that have been used once and may be needed again shortly.
An example of caching (NOT CPU)
Web caching - the storing of HTML pages and images recently viewed. Gives fast access to pages that have been recently looked at and saves having to download pages again, using up unnecessary bandwidth.