212-thinking-ahead-elements-of-computational-thinking Flashcards
Thinking ahead
- how the diff components of problem will be handled in the best way. determine desired output by backtracking to figure out inputs
- preconditions and caching
- how will inputs be captured/processed to output
- identify problems that may arise so developer can design strats at the early stage to make program intuitive
- identifying reusable program components
Inputs and outputs
info relevant to problem,
- data signals received from an external source
- Input can be manual e.g mouse or automated e.g sensor
- specialised devices: sip/puff switches, foot switches, Braille keyboards for disabilities
- data signals produced by a system as a result of processing inputs
- digital data from a computer system into a format that humans can process (sound, images, vibrations)
- directed into other places e.g users, devices,
.
- directed into other places e.g users, devices,
Specifying preconditions benefits
- documented preconditions make well-defined componenets/modules that can be reused (understood behaviour, no ambiguity)
- cutting out unnecessary checks (clear, necessary, shorter programs -> ezer debug and maintain
- expected validation
Caching in thinking ahead
anticipiate what the program will need based on preconditions and precache it
last few excecuted instructions of program, result of earlier computation, data used
all stored in memory for quick retrieve
pros and cons of caching
faster access to resources, save cost use bandwidth, reduce load on web service, speed up process
can be complicated to implement, requires the correct data to be fetched for the next instruction, consistency with source update, larger caches take longer to search
Outputs
Solution to problem passed back from subroutine
Preconditions
current state/requirements that must be met for program to run successfully/execute
if not met, will fail to execute or return invalid result
specifiying preconditions means arguments passed in subroutine expected meet criteria
- can be in documentation or tested for within code
- ensure that the necessary checks are carried out before the execution of a subroutine, either by the user or as part of the subroutine. By explicitly ensuring these conditions are met, subroutines are made more reusable
arguments
the values passed into the parameters of a subroutine
prefetching
algorithms predict which instructions are likely to be soon fetched, are loaded in cache before fetched/required
less time waiting
predictive logic difficult to implement, accuracy no guarantee, wrong data cached has to be flushed,
reusable program components in thinking ahead
commonly used functions -> libraries
- more reliable than new as already tested
- saves money time resources
- reduce redundant code
- possible compatibility issues -> need modification (more costly/time)
- External reuse - reselling a component to a third party, developers leveraging the power of other developers’ software
API (application programming interface)
interface where software system can interact with another.
- standardises how requests and responses should be structured, including data formats (e.g., JSON, XML) and communication protocols (e.g., HTTP, REST).
- defines specific functionalities or services that applications can use through it. This can range from retrieving/accessing data (e.g., weather information, user profiles) to performing actions/methods(e.g., making payments, sending notifications).