Sequence
the code is executed line by line, from top to bottom (sequentially)
Branching/ selection
BRA - always branch
BRP - branch if the value is positive (or zero)
BRZ - branch if the value is zero
A certain block of code is run if a specific condition is met, using IF statements
Iteration
A block of code is executed a certain number of times (FOR loop) or until a condition is met (WHILE loop)
What is Recursion
Advantage of Recursion
The code is represented in fewer lines of code
Disadvantages of Recursion
Global Variables
Can be accessed across the whole program
Global variable disadvantages
- requires more memory as they aren’t deleted once the subroutine is completed.
Local variables
local variables have a limited scope which means that they can only be accessed within the subroutine in which they were defined in
Local variable advantages
Modularity (top-down programming)
Splitting large, complex problems into smaller self-contained modules
- makes it easier to divide tasks between a team as each component is self contained
Procedure and function similarity
Procedures and functions are both named blocks of code that perform a specific task
Procedure vs function
Procedures don’t have to return a value whereas a function must always return a value
IDEs
Class
A class is a template for an object and defines the state and behaviour of an object It is not an object itself. It is a template used to set or define what attributes and methods an object has. Once you have defined a class, you can easily reuse that class and create many objects of that class.
Inheritance
subclasses inherit methods and attributes from the superclass. Using inheritance, you can reuse the code from a class and extend its attributes and methods.
Encapsulation
When attributes are made private.
Public methods are needed to read/ amend the attribute’s value
- used to hide values or the internal state of an object preventing direct access by unauthorised third parties
- reduces human error
Object Orientated Techniques
Attempts to capture or group info and data and related functionality (code) into structured items known as objects.