2.1.2 Thinking ahead
No description yet. This curated deck is ready for daily study.
Card preview (13)
Thinking ahead helps:
Maximise code efficiencies Minimise errors
How do we determine what inputs are needed for a system
Start with the output and from there find out what you need and the processes to get that output
If we want to find the volume of a fish tank, what will the inputs, process and outputs be
Inputs: length: real / float Width: real / float Height: real / float Process: Length x width x height Output: Volume: real/ float Process
What are preconditions
Conditions that already exist and could affect how you devise a solution to a problem
What can preconditions affect when attempting to solve a problem
Time Cost The overall quality of the solution
Advantages of caching
Quicker than retrieving items from secondary storage Improves efficiency Takes less time One live of code can be used multiple times Use of functions Use of classes Use of external libraries
Disadvantages of cache
Complicated to implement If the cache contains outdated or incorrect data, the wrong data is often retrieved and needs to be removed/ flushed Maintaining the correct sequencing of instructions or data items can be problematic
What is prefetching
Data being requested before it is actually needed
What is caching
The process of temporarily storing copies of frequently used data or instructions in small, fast memory This is quicker and more easily accessed than main memory This increases speed and efficiency of the system Eg. A CPU can store recently used instructions from RAM so the processor can use them faster net time
What are the benefits of reusing code made and tested by a previous developer
Shortens developing time Saves system resources Lowers development costs Reduces redundant code Pointless to write more- potentially flawed- code when perfectly good code already exists
What is an example of reusing code
Libraries Allow developers to use code that has been prewritten and tested code Methods/ subroutines In our code we use methods and subroutines — like functions and procedures — that we call instead of writing the same code multiple times.
What is external reuse?
Reselling components to a third party Eg. Facebook offers integration with other programs and software platforms May also use google, x, or facebook to log into other platforms
Benefits of external reuse
Developers can pull in contacts from friends lists The systems being linked also allows certain procedures and functions to be available to other developers via API