2.1.2 - thinking ahead Flashcards
10
1
Q
A
2
Q
Why do we need preconditions?
A
To ensure the function never crashes.
3
Q
advantages of specifying preconditions
A
- Ensures that the user knows what checks must be carried out before calling the subroutine.
- If there are no preconditions, the user can be confident that necessary checks will be carried out in the subroutine itself, saving unnecessary coding, making it easier to debug and maintain.
- Makes the subroutine reusable.
4
Q
benefits of code reuse
A
- shortens development time
- saves system resources
- lowers development costs
- reduces redundant code
5
Q
advantages of pre-written routines
A
- Already compiled so they are tested and error free.
- Saves work for programmers, shortens overall development time and reduces costs.
- May be used multiple times.
- May have been written in a different source language.
- Allows the programmer to use other prorammers’ expertise and is a more standardised approach to coding.
- May require fewer developers to work on a project.
6
Q
caching
A
The temporary storage of program instructions or data that have been used once and may be needed again shortly.
7
Q
advantages of caching
A
Improves speed and efficiency.
8
Q
disadvantages of caching
A
- The nature of predictive logic means caching algorithms can be very complicated to implement.
- The wrong data is often fetched and cached, therefore it has to be removed/flushed.