Please enable JavaScript.
Coggle requires JavaScript to display documents.
A Level Computing Notes (End of Year 12 Exams 2022) - Coggle Diagram
A Level Computing Notes
(End of Year 12 Exams 2022)
Computational thinking
Computational thinking is defined as just a way of approaching problems - i.e. first phrasing the problem as a question that could be answered with an algorithm then creating said algorithm. The created algorythem should be both
effective and efficient
Abstraction
Types
Representational Abstraction
This is the typical description of abstraction, removing necessary details from a scenario.
Examples
Tube map :
Good points: Easy to follow for commuters as lines are simplified
Bad Points: Don't accurately show distance between lines and thus could not be used to determine the position of a new line.
Definition - Creating a model of reality in which unnecessary information is omitted so as to improve comprehensibility of a situation.
Abstraction by Generalisation
Sometimes, generalising a problem can make it significantly easier to deal with - for example allowing one to create mathematical proofs for it.
This process was demonstrated by Euler with his bridge problem. A city with 7 bridges wanted to know if they could cross each bridge at least once. His abstractions were able to turn a bridge map like below into a simple node diagram.
He created a vastly simplified diagram that showed how many connections each area of land had. He then noticed that all 4 nodes had odd number of bridges connecting them. He said that in order for a route to be established that one could only cross each bridge once, every node excluding the start and end node must have
even
numbers of connections. This thus proved that it was impossible.
This was a great abstraction as Euler had just created a general formula for a specific scenario by generalising it.
Procedural abstraction
This is defined as removing information about the implementation of a function from the user so they are not required to understand how it works. For example, the
interface
on a smartphone hides actually communication with WiFi access points.
High level programming languages are, by definition, abstractions as they hide away some of the low level features present in, assembly - like choosing where a variable will be stored. This makes it easier for the programmer to make time for the actual logic work.
Initial languages were binary and low level and consequently even writing a simple algortythem using one was a difficult and highly involved process.
Procedural abstraction works in such a way that the end user does not need to know how something works but simply the method in which to use it
In programming this is implemented for example when you use libraries like tkinter. You can use functions like drawSquare without understanding quite how they operate and draw things on the screen
A programmer can then use this procedure to write their own procedure that would, for example, draw a representational abstraction of a house
Such a system is known as procedure interface as you interface with an algorithm though the method of procedures
Data abstraction
This is the idea that data is represented using abstract concepts and thus the actual method in which the data is represented is hidden. For example, as a preprogrammer, you don't have to consider how a string is saved in memory, it is just automatically translated to binary and stored in that form.
Another example of such a data type may be a que - a data type that allows a item limited list of objects in a list. In python for example this may be implemented using lists but this information is hidden from the user.
Computing is sometimes known as the automation of abstraction
Computing is about having the ability to decompose a computational problem from a problem of other variety other other problems
Hierarchy Charts
A tool for a program that shows how a larger problem can be broken down into smaller modules or steps
An example of a hierarchy chart
Thinking Ahead
In order to think about a problem in advance it is necessary to consider a problem in its most abstract form -
Input : Process : Output
In order to consider a problem it is essential to determine exactly what are inputs will need to be. This is usually done be considering first the output before calculating what data will be inputted to create this given output
Inputs should be the data that is specific to the problem in question and should always be specific for example specifying the data type
In order to determine a solution to a problem you need to know if there are any
preconditions
or facts of life that exist already as you program will have to content with these in its functionality
Advantages
Can save work on necessary checks
Example, if you were given a task to write robust subroutine capable of sorting a list then you may be tempted to include checks to ensure that the list is not empty. This extra work could, however be avoided if it was a guaranteed precondition that the input list would always be non-zero
Can help to mitigate any unwanted realisations if your code is not compatible with a certain piece of existing infrastructure.
Documenting preconditions can help a potential user of your code understand what setup they will need to do in order to implement it into their own scripts
Modularisation of code
This is the practise of breaking down code into smaller chunks or modules
Includes:
Use of local variables
Use of subroutines
Advantages
Easy to work on the program as a team
Easier to debug the working of the system
Makes it possible to reuse some components in other instances in the program or in a different project all together
These are essential as they can prevent repeated code and thus save a huge amount of time.
Using libraries has similar benefits including the time saving factor but also the fact that library code is infinitely better tested and thus more robust for a deployment
Libraries can, however lead to extra weight being added to a program as the majority of functionality is often not utilised. They are also sometimes quite old and fragmented and may not be written in as efficient a manor as one may expect
If one is thinking ahead, it becomes possible to use
caching
Caching involves the
temporary storage of information and instructions that have recently been used so as to use them again shortly
Caching of files is in a similar vain - e.g. on the web where files are stored on the client computer so as to reduce network requests and traffic to the server.
Thinking Concurrently
According to the A-level specification, concurrency can have two basic meanings
Parallel Processing
when multiple instructions are genuinely being executed at the same time using a multi-core CPU or using a cluster of macheins
Benefits
Can rapidly speed up a task as multiple cores are executing it at the same time
Graphics processors for example can render images at a much quicker rate using this
Browsers will sometimes use this to allow multiple tabs to run at the same time
Drawbacks
Some tasks just cannot be run in parallel as they require the output of a previous instruction to be given in order to complete the next one
Some processing must be used to coordinate the distribution of tasks that can lead to a performance degradation
Concurrent Processing
on the other hand can be done on just a single core and this involves giving multiple programs each a slice of processor time
Benefits
The number of tasks overall completed in a given period may be greater
Time that would otherwise be wasted -e.g. waiting for user input can be utilised
Drawbacks
Some longer tasks will keep getting swapped out of the current execution and will thus take longer
Programming Techniques
Recursion
🔑 Recursion is defined as the when a subroutine calls itself from within the procedure or function
What is recursion good for?
Traversing trees and graphs
Searching systems
Code written recursively will often comprise of less lines of code than a comparable iterative routine
Where is iteration better?
Where a process needs to run a certain number of times
Key terms
Base Case : When the recursive routine ceases to call itself again
General Case : What will normally happen (i.e. when a program does make a recursive call
Stopping condition - The value[s] for which the function will return a definite value (i.e. will no longer recurse)
Local and global variables
Where are local variables preferable?
Basically everywhere
They allow for subroutines to be independent of one another
This means that a number of contributors can more easily collaborate on a project without breaking one another's programs
Local variables make it easier to follow what is going on in a program as you do not have to search through an entire file to find where a value was declared
Local variables : Variables that are only accessible from within the current scope
Global variables : Are accessible from the entire program
In the case where there is a local and global variable that share the same name, global variables usually take precedence.
By-Value and By-Ref
By-Ref : The variable passed into the subroutine is the same memory location as it is in the main program. This means that the value is updated in the main program without needing to return the value manually
Uses less memory
Faster as no copy is required
Can make multiple changes to variables from within a funciton
Harder to test independently
By-Val : The variable is copied in memory so that when it is modified by the subroutine it remains the original value in the main program execution
After the program execution has finished, the variable is popped from the stack
Since you may only return a single value from a function, you cannot get many values from a function with the byVal method
Allows for more independent subroutines
Uses more memory
Marginally slower as the value has to be copied in memory
IDEs
Make programming easier by providing development tools
Editor
Features
Syntax highlighting
Syntax checking
Compiler
Compile the code down into machine code so that it can be executed
Debugger
Features
Breakpoints
Object Oriented Programming
Key Words 🔑
Class - a definition of objects
Polymorphism - The idea that a single class definition can be used to instantiate a number of objects
Instance - A populated version of a class
Instantiation - The act of creating an instance of a class
Getter - A method that returns the value from an attribute
AKA Accessor
Setter - A method that updates the value of an attribute
AKA Mutator
Components ⎄
Constructor
A subroutine that is executed when the class is instantiated
Pseudocode :
PUBLIC PROCEDURE new()
Method
A subroutine within a class that can be executed
Attribute
A variable within a class that can contain a value
Inheritance
Allows a class to inherit the parameters and methods of another (parent) class.
The parent class is often called the superclass and can be referenced with the
super
keyword
Encapsulation
This describes the process of keeping the
attributes
of a class kept as private. This means that the only way to interact with these values is to use getter and setter methods
This has the benefit that the creator of the class can implement protections into the getter and setter methods that stop a user assigning attributes arbitrary or erroneous values.
OOP is a form of programming paradigm
Software & Software Development
Exchanging Data
Components of a Computer