Please enable JavaScript.
Coggle requires JavaScript to display documents.
Elements of computational thinking - Coggle Diagram
Elements of computational thinking
Thinking abstractly
The nature of abstraction
Representational abstraction:
Removing excessive details to represent a problem using only the key features
Must analyse what is relevant to a scenario and simplify a problem based on this
Data abstraction:
Details about how data is being stored are hidden
Programmers can use data structures without knowing how they are implemented
Layers of abstraction:
Large, complex problems are split into layers of abstraction
Each layer has a different role, with the highest layers being closest to the user
These are usually responsible for providing a user interface
The lowest levels perform tasks such as interacting with machine components
Abstraction by generalisation:
Grouping together similarities within a problem to identify what kind of problem
Allows problems to be categorised as being of a particular type
A common solution can be used to solve these problems
Procedural abstraction:
Allows programmers to utilise functions without knowing how they are implemented
Used in decomposition and manipulating data structures
Models what a subroutine does without considering how, as once a subroutine as been written, it can be reused as a black-box
The need for abstraction
Abstraction allows non-experts to use a range of systems or models by hiding information that is too complex or irrelevant to the system's purpose
Enables for efficient software design as programmers can focus on core elements rather than unnecessary details
Reduces the time spent on a project
Prevents a program from getting unnecessarily large
Programming languages use layers of abstraction:
Low-level languages directly interact with computers but are difficult to write
High-level languages abstract the machine code that is executed when a program is run by providing easy-to-use syntax similar to natural language
Makes developing programs easier
High-level languages are easier to learn and use than assembly language or machine code
Makes coding accessible to non-specialists
The TCP)/IP model is an abstraction for how networks function, separated into four layers: application, transport, internet and link
Each layer deals with a different part of the communication process
Each layer does not need to know how other layers function
The difference between abstraction and reality
Abstraction is a simplified representation of reality
Entities are represented as computational structures e.g. tables and databases
Real-world values can be stored variables and constants
Objects in object-oriented programming are an abstraction for real-world entities
Attributes represent the characteristics of an object
Methods represent the actions a real-world object is able to perform
Devise an abstract model for a variety of situations
When devising an abstract model given a scenario, you must consider:
What is the problem that needs to be solved by the model?
How will the model be used?
Who will the model be used by?
Which parts of the problem are relevant based on the target audience and purpose of the model?
Thinking ahead
Inputs and outputs
Designing a solution requires thinking ahead about how the different components of a problem can be handled in the best way possible way
By thinking ahead, developers can build programs that are easy and intuitive to use
All computational problems consist of inputs which are processed to produce an output
Inputs include any data required to solve the problem
These are entered into the system by the user
Outputs are the results that are passed back
Outputs are produced once inputs have been processed
Outputs are essentially the solution to the problem
You should be able to evaluate the methods using which this data is captured, or relayed back to the user once processed
Consider data structures and data types involved
Consider input and output devices
Designers begin by considering the outputs based on the user's requirements
This is used to identify the inputs required and how these need to be processed to achieve these outputs
Preconditions
Requirements which must be met before a program can be executed
Can be tested for within the code or included in the documentation accompanying a particular subroutine, library or program
Specifying preconditions means that a subroutine expects the arguments to be passed to it to meet certain criteria
Preconditions make subroutines more reusable
Reusable program components
Commonly used functions can be packaged into libraries for reuse
Teams might create a library of components so they can be reused throughout a project. Reusable components include:
Abstract data structures e.g. queues and stacks
Classes
Subroutines e.g. functions and procedures
Problem decomposition is used to identify where previously-developed program components can be reused
Reusable components are more reliable than newly-coded components, as they have already been tested
They save time, money and resources
Components may need to be modified to be compatible with existing software
This can be more costly and time-consuming than developing them from scratch
Caching
Storing instructions or values in cache memory after they have been used, as they may be used again
Saves time of retrieving instructions from secondary storage again. Frequently-accessed web pages are cached so content can be quickly loaded
This frees up bandwidth for other tasks on a network
Prefetching is when algorithms predict which instructions are likely to soon be fetched and are loaded and stored in cache
Thinking ahead means less time spent waiting for instructions to be fetched
Limited by accuracy of algorithms used, as data stored in cache is not always used
Effectiveness depends on caching algorithm's ability to manage the cache:
Larger caches take a long time t search, but smaller cache sizes limit how much data can be stored
Can be difficult to implement well
Thinking procedurally
Identify the components of a problem
Breaking a problem is the first stage of thinking procedurally
This process is called problem decomposition
This breaks a large, complex problem down into smaller subproblems which can be solved more easily
The project becomes easier to manage and can be divided between a team
Top-down design, also known as stepwise refinement, is commonly used to do this
This divides problems into levels of complexity
Problems are broken down into subproblems until each subproblem is a single task
Each subproblem can then be solved using a single subroutine
Subroutines can be developed and tested separately, so they are self-contained
Components of a solution and sub-procedures
Details about how each component is implemented are considered
Just as we broke down the problem, we now build-up to its solution
Need to consider the lowest-level components from top-down design and how they can best be solved
Can this be implemented as a function or a procedure?
What inputs are required?
What output does the subroutine need to produce?
Tasks which can be solved using an already existing module are identified
Order of steps needed to solve a problem
When constructing the final solution, thinking about the order in which operations are performed is important
Programs may require certain inputs to be entered in a particular order by the user before processing can occur
Inputs need to be validated, and this must occur before this data is used
In some cases, it may be possible for several subroutines to be executed simultaneously depending on the data and inputs the subroutine requires
Programmers should decide on the order in which subroutines are executed, and how they interact with each other, based on their role in solving the problem
Programs should also be built so operations cannot be carried out in an order that will raise an error or does not make logical sense
Thinking logically
Decision making in problem solving
A decision is a result reached after some consideration
When solving problems and designing programs, many decisions have to be made
Examples including choosing the programming paradigm used and deciding how different information is collected from the user
To simplify the decision making process, we limit the solutions we can pick from
When deciding on a programming language, you should consider what is suited to the task and your understanding of the language
Identifying where decisions need to be made early allows us to gather enough information about our options
In flow charts, a decision is shown by a diamond shaped icon. It can have two results, yes or no (true/false)
Conditions that affect the outcome of a decision
When making a decision, there are certain factors which determine the outcome you choose
What is most effective?
What is most convenient?
Is this option reasonable?
To make an appropriate decision, you need to evaluate these conditions
It is also helpful to order them from most important to least important
This makes it clearer how best to achieve your solution
Decisions affecting the flow of a program
Decisions are made to determine how different parts of the program are completed
Say we are tasked with designing a simple runner game. We could design the game to be endless, or level-based
These decisions produce different routes through the program
It is also important to identify where decisions need to be made within the program, and plan out the outcomes of the decision made
Again, the program follows a different route depending on the decision made by the user
Thinking concurrently
Concurrent thinking
Concurrent thinking is the process of completing more than one task at a given time
Does not always mean you have to be working on multiple tasks at once
Involves giving 'slices' of your time to different tasks
Parts of a problem which are related can often be solved concurrently
Concurrent processing
Concurrent processing and parallel processing are not the same thing
Parallel processing is when multiple processors are not used to complete more than one task simultaneously
In concurrent processing, each task is given a slice of processor time to make it appear as if tasks are being completed simultaneously
In reality, tasks are executed sequentially
Benefits of concurrent processing
The number of tasks completed in a given time is increased
Less time is wasted waiting for an input or user interaction, as other tasks can be completed in this time
Drawbacks of concurrent processing
Concurrent processing can take longer to complete when large numbers of users or tasks are involved as processes cannot be completed at once
There is an overhead in coordinating and switching between processes, which reduces program throughput
Just as with parallel processing, not all tasks are suited to being broken up and performed concurrently