2.1 - Elements of Computational Thinking (2.1.1-1.2) Flashcards
Define Abstraction. (2 Definitions)
- Abstraction is the process of separating ideas from reality
- It is a means of hiding unnecessary details to focus on the main purpose of a problem
Subcategories of Abstraction
- Data abstraction - When details about how data is being stored are hidden
- Representational Abstraction - Analysing what is relevant to a given scenario and simplifying a problem based on this information.
- Abstraction by Generalisation - Involves grouping together similarities within a problem to identify what kind of problem it is
- Procedural Abstraction - Models what a subroutine does without considering how this is done
State two advantages of using Abstraction in Software Development.
- Easier for programmers to focus on the main purpose of a program; thus reducing the time needed to spend on the project
- Reduces the complexity of programming; thus reduces memory and processing requirements
- Prevents program from becoming unnecessarily large
Where can we see Abstraction in Computer Science?
- Applications
- Networks
- Operating Systems
- Data Structures
- Databases
Potential Dangers of Abstraction
- Potential ‘Over-Abstraction’ which can lead to details that are actually important being removed
- Too much abstraction can detract from the engagement and appeal of programs like games as they may be too simplistic
- May make some simulations not realistic enough
General Premise of Thinking Ahead
- Thinking ahead about the different components of a problem and the best way to handle them; allowing developers to consider potential problems or difficulties that could arise.
- Taking these factors into account early allows developers to design strategies to make programs easy and intuitive to use.
What is a Precondition?
Preconditions are requirements which must be met before a program can be executed. If the preconditions are not met, the program will fail to execute or return an invalid answer.
Advantages of Stating Preconditions in Documentation of a function
- Reduces length and complexity of program
- Easier to debug and maintain
What are the preconditions of binary search tree?
Data must be stored in a tree structure and ordered
What are the preconditions of binary search?
Data must be in order and must be in a structure where elements can be directly accessed
What are the preconditions of linear search?
Data must be in a structure that is iterable
What are reusable Program Components and how they are used when developing large programs
- Commonly used functions that can be identified when a problem is split into components
- Software is modular (E.g. object/function) and these modules can be transplanted into new software or shared at run time through the use of program libraries.
Advantages of Reusable Program Components
- Makes programs easier to maintain as sections can be tested independently and updates to a specific module will update all parts of a program that use it
- Will save time as code doesn’t have to constantly be re-written
- Modules of code have already been tested; code is more reliable
What is Caching?
It is temporary storage of program instructions or data (that have been used recently and may be used again) in cache; allowing for quicker access for future use
What is Prefetching?
Where an algorithm predicts which instructions or data are likely to be required by a program. The data likely to be needed next is fetched and stored in a cache ready to be used by the program.