2. 1. 2 Thinking Ahead Flashcards
1
Q
Inputs and Outputs
A
- Must be able to outline what the inputs and outputs are in a given scenario
- Must be able to explain why you have chosen these
- Must be able to outline how the data is captured or relayed back to the user
2
Q
Preconditions
A
- Requirements which must be met before program can be executed, if not met the program will fail to execute or return an invalid answer
- Preconditions can be tested for within the code but are more often included in the documentation accompanying the code
- Think of preconditions as sensible restrictions that are essential to the success of the solution, can have implications on the time and cost of the solution
- In the case of prepping a meal for friends, the preconditions would be, number of friends, available time, costs, dietary requirements etc
- In an exam, in real life scenarios you need to discuss some realistic preconditions that could affect the solution
3
Q
Caching and Prefetching
A
- Process of storing instructions or values in cache memory after they have been used, may be used again
- Saves time, closer to retrieve compared to going back to secondary storage again
- Web pages usually cached, content can be loaded without any delay, images and texts don’t need to be redownloaded multiple times, frees up bandwidth for other tasks on a network
- Prefetching is a more advanced variation of caching, algorithm predict which instructions are likely to soon be fetched, loaded and stored in cache before they are fetched (actually required)
- Less time spent waiting for instructions to be loaded into RAM from the HDD
- Limitation, accuracy of algorithms used, no guarantee that instructions fetched will actually be right
- Effectiveness off caching dependent on how well caching algorithm is able to manage cache
- Larger cache still takes time to search cache size limits how much data can be stored
- This form of thinking ahead is difficult to implement but can significantly improve performance if implemented effectively
4
Q
Reusable Program Components
A
- Commonly used functions often packaged into libraries for reuse
- Teams working on large programs may also use certain components in multiple places, may put together a library so these components can be reused
- Reusable components include, implementations of abstract data structures (stacks, queues), classes and subroutines
- When designing software, problem decomposed (broken down into smaller simpler tasks), allows devs to think ahead about how each task can be solved
- Allows them to identify where program components developed in the past or externally-sourced program components (third-party) can be reused to simplify the development process
- For example, BOTW 2 used old models to reduce the overall time to develop the game (did not have to remake older models, spend time on new ones)