Abstraction
Separating ideas from realityā¦
by removing irrelevant detailsā¦
to create a focused representation of reality.
How to/why abstract?
Remove unnecessary elementsā¦
to reduce unnecessary programmingā¦
which would require extra computational resourcesā¦
and detracts from the main purpose of the program.
Realities relationship to Abstraction
Abstraction is a simplified version of reality in whichā¦
real-world entities are represented as tables in databases andā¦
real-world values are stored as variables and constants.
Thinking Ahead + why do it?
Identifying theā¦
Preconditions
Inputs
Outputs
Reusable components
Caching
ā¦of a system.
We do this to maximise efficiency and minimise errors.
Preconditions
Conditions that must be true for an algorithm to complete successfully without errors. For example:
A binary search algorithm must be supplied with an ordered list.
Reusable Program Components + Benefits/Drawbacks
Commonly used functions are packaged into libraries.
Reusable components like:
Classes
Subroutines (Functions or Procedures)
Abstract Data Structures (Queues & Stacks)
+ More reliable than new code as theyāve been tested.
+ Saves time, money, and resources.
+ Can be used in future projects.
- Components may need to be modified to be compatible with a project.
Caching + Benefits/Drawbacks
Storing instructions/data in cache memory after theyāve been used as they might be frequently used.
+ Faster than RAM or Secondary Storage so saves time
- Cached data may not reflect latest updates to that data. (E.G a webpage you frequent may be cached, but it may have been updated since you last visited)
What is Thinking Procedurally?
Decomposing a problem to identify itās components.
Sequence, Selection, and Iteration (Branching)
One statement after another
Code is executed line by line, from top to bottom
Decision-making points (if else, switch case)
Loops (for, while, do until)
What is Thinking Concurrently?
Identifying parts of the problem that can be tackled at the same time.
Concurrent Processing
When system appears to do multiple things simultaneously (on one core) but it kinda switches between them really quickly so they are done āat the same timeā.
āOne process does not have to finish before the other startsā - mark scheme
āProcesses are happening at the same time / at overlapping timesā + āOnly 1 process can actually happen at a time on a single core processor, concurrent tries to simulate multiple processesā
What is a Procedural Programming Language?
A high-level language that gives a series of instructions in a logical order. (what to do and how to do it)
What is a Parameter and how to pass to a subroutine?
Data structures that are passed into a subroutine when called.
By Value: A local copy of the data in the variable is used, and then discarded, so the original data is unaffected.
By Reference: Reference to the variable's memory location is passed to the function, which means the actual value is affected.
Variables + Scope
Identifier of a memory location used to store data.
The range that a variable is accessible for.
Local Scope:
Accessible in the subroutine that it was defined in.
Eraed when subroutine ends
+ Ensures subroutines are self-contained
Global Scope:
+ Accessible across the entire program.
+ Risk of being unintentionally edited.
- Requires more memory as not deleted until the program ends
What is an IDE? + Features?
Integrated development environment. A single program that is used to develop programs.
Syntax highlighting to identify mistakes quickly
Stepping to run one line at a time and check the result
Variable watch to check the value of variables during execution
Error messages to locate errors
Breakpoints to stop and test the program works up to certain points
Recursion + Essential features?
Routine calls itselfā¦
and has a stopping conditionā¦
which must occur after a finite number of calls.
Function vs Procedure
A block of code with a unique name to call it to complete a task. Takes parameters.
Function is Fun so returns a value.
Procedure does not return a value.
Recursion Vs Iteration
Recursion:
+ Fewer lines of code
+ Better for a problem canāt be solved with a fixed amount of memory.
More likely to cause a stack overflow
Iteration:
+ Easier to follow/understand
+ Faster
Benefits/Drawbacks of Concurrent Processing?
+ More tasks completed in a given time.
+ Less time wasted waiting for input/interaction, as other tasks can be completed during the waiting.
- May take longer when a lot of users/tasks are involved.
- Long to coordinate and switch between processes.
- Task may not be suited to be broken up and performed concurrently
Class, Object, Attributes in OOP
A Template of an object that defines the state (attributes) and behaviour (methods) of objects.
An instance of a class
Benefits of OOP
Modular
pluggable
protected
reusable
faster development
Encapsulation
Bundling attributes and methods together within a class.
Ensures data remains secure and is not unintentionally modified (by making attributes private)
Hides complexities
Polymorephism
Backtracking
When an algorithm finds a solution by trying different sequences and abandoning a path that leads to an invalid solution.
Data Mining
Identifies patterns and trends in large data sets.
Pipelining
Breadth First Traversal
From left to right, visit children of root/start node. Then visit children of each of those nodes, still left to right. Continuing until every node has been visited.
Depth-first (Post order)
Goes as far into the tree as possible. Goes to the left child node when possible, if not possible then goes to the right. When it getās to the point of when a node has no children, it visits that node. Backtracks to the previous node, attempts to go right, if it can, then contin
Performance Modelling
Testing a system before it is used by users.