1.2.4 Types of Programming Language Flashcards
Define programming paradigm
A style of programming
Define procedural programming
When every variable, constant, and subroutine is defined separately, with no relationship between them
Define object-orientated programming
Separate objects are defined with their own subroutines and values
Define a constructor
A method that creates an object of a particular class with its own attributes
Define a static attribute or method
Attributes or methods relevant to a whole class
Define a non-static attribute or method
Attributes or methods that are relevant to only the object
What are some features of procedural programming?
- The programmer specifies steps needed to be executed
- The order of the steps is up to the programmer
- Statements can be grouped into procedures and functions
What are some features of object-orientated programming?
- The programmer can design self-contained objects
- Each object contains methods and the data that is being processed
- The program is split into smaller units (objects)
- Objects can be reused and inherited easily
What are some features of assembly language?
- Low-level language
- Has a one-to-one relationship with machine code
- Uses mnemonics to represent machine code
- Specific to a processor
Define homogeneous elements
All elements have the same data type
Define heterogeneous elements
Elements can have different data types
What is the typical size and explanation of an integer data type?
2 or 4 bytes
A whole numerical value
What is the typical size and explanation of a real/float data type?
4 or 8 bytes
A decimal value
What is the typical size and explanation of a string data type?
Usually 1 byte per character
A set of character and/or numbers
What is the typical size and explanation of a boolean data type?
1 bit
Can be one of two values
What is the typical size and explanation of a character data type?
1 byte
A single letter, digit, or symbol
What is the typical size and explanation of a date/time data type?
1 byte per date or time
A value that states the date or time:
DD/MM/YYYY or hh:mm:ss
What is the typical size and explanation of a currency data type?
8 bytes
A real/float value which is told which currency symbol to assign to it
What is the basic structure of a 16-bit machine code instruction?
Opcode (operation code): basic machine operation (6 bits) and addressing mode (2 bits)
Operand

ADD: instruction, numeric code, and description
ADD
1xx
Adds the contents of the memory address to the Accumulator
SUB: instruction, numeric code, and description
Subtract
2xx
Subtracts the contents of the memory address to the Accumulator
STA: instruction, numeric code, and description
Store
3xx
Stores the contents of the Accumulator to the memory address
LDA: instruction, numeric code, and description
Load
5xx
Loads the contents of the memory address to the Accumulator
BRA: instruction, numeric code, and description
Branch always
6xx
Branches to the instruction in the memory address
BRZ: instruction, numeric code, and description
Branch if zero
7xx
Branch if the contents of the Accumulator is 000 to the instruction in the memory address
BRP: instruction, numeric code, and description
Branch if positive
8xx
Branch if the contents of the Accumulator is positive to the instruction in the memory address
INP: instruction, numeric code, and description
Input
901
Input data which is copied to the Accumulator
OUT: instruction, numeric code, and description
Output
902
Output the contents of the Accumulator
HLT: instruction, numeric code, and description
Halt
000
End the program
DAT: instruction, numeric code, and description
Data
-
Used to indicate a location that contains data
Where is memory addressing used?
In low-level languages
What are the 4 types of memory addressing?
Immediate addressing #
Direct addressing &
Indirect addressing ~
Indexed addressing []
Explain immediate addressing, stating the symbol used in LMC
#
Nothing is fetched from memory, the operand contains the data to be used
Explain direct addressing, stating the symbol used in LMC
&
The operand contains the memory address of where the data to be used is stored in memory
Explain indirect addressing, stating the symbol used in LMC
~
The operand acts as a pointer towards a table in memory. The address of the data needed is retrieved from that table
Explain indexed addressing, stating the symbol used in LMC
[]
The final address of the data is calculated by adding an offset to a base address. An array has a base address which the operand will point to, and then the base address is incremented to reach each subsequent data value
What are the advantages and disadvantages of immediate addressing?
Advantages
- Useful when dealing with short constants
- Very fast
Disadvantages
- Not useful with variables or long values, since the data is restricted by the size of the operand
What are the advantages and disadvantages of direct addressing?
Advantages
- Fast
Disadvantages
- Slower than immediate mode
- The space for the address is limited by the size of the operand
- Doesn’t allow for re-locatable code
What are the advantages and disadvantages of indirect addressing?
Advantages
- More space for addresses as isn’t limited by the size of the operand
Disadvantages
- Slower than direct addressing
What are the advantages and disadvantages of indexed addressing?
Advantages
- Fast
- Great for manipulating data structures
- If the array is relocated, only the base address needs to change
Disadvantages
- Slower than direct addressing, since calculations need to be performed
Define an Object
One member created from a class, with attributes and methods shared between objects
Define an attribute
Essential features or characteristics of the object created from a class
Define a class
The overall blueprint of a set of objects
Define a method
Describes what actions the object can do
How do private attributes and methods differ from public ones?
Private attributes and methods can only be accessed through getters or setters
What does a get and set do?
Getter: method which returns the value of a private attribute
Setter: method which lets you change the value of a private attribute
What are the advantages of using OOP?
- Prewritten classes support code reuse
- Classes can be easily extended with child classes
- Easy to manipulate, as highly modular
- Encapsulation can provide high levels of protection for data
What are the disadvantages of using OOP?
- A system relying on message passing can be less effective
- Inheritance could use unwanted attributes or methods to be acquired
- Objects can take up a relatively large amount of memory
Define instantiation
This is the name for creating an instance of a class
Define encapsulation
This is the process of causing an attribute to be private, meaning the user is unable to directly edit it
Define inheritance
A class (subclass) taking on attributes and methods from another class (superclass)
Define polymorphism
A method or attribute which can take many forms.
This happens when they are overridden by a subclass
Define a subclass
A child class which takes on the attributes and methods of the linked parent class
Define a parent class
A parent class with attributes and methods
What are the 5 types of programming paradigms?
Functional
Object-oriented
Procedural
Low-level
Declarative
What are the features of the functional programming paradigm?
- Designed around using mathematical functions, conditional expressions, and recursion
- Supports higher-order functions and lazy evaluation
- Doesn’t support flow controls (e.g. loops/conditionals)
- Supports abstraction, encapsulation, inheritance, and polymorphism
Define higher-order functions and lazy evaluation
Higher-order functions: functions that call other functions as arguments or in some way
Lazy evaluation: an expression is only evaluated when it is needed
What are the advantages of the functional programming paradigm?
- Efficient: consists of independent units that can run concurrently
- Supports lazy evaluation
- Supports higher-order functions / nested functions
What are the disadvantages of the functional programming paradigm?
- Complex as it is rooted in mathematics
- Recursion is memory expensive
What are the features of the object-oriented programming paradigm?
- Parts of the system are categorised as objects, made from classes
- Classes use set attributes
- Subroutines are named methods and identified within classes
What are the advantages of the object-oriented programming paradigm?
- Often easier to think in objects than procedurally
- Promotes and supports code reuse
- Classes are highly modular and easy to maintain
- Encapsulation provides data protection
What are the disadvantages of the object-oriented programming paradigm?
- The system is often very large and complex
- Inheritance can have unintended consequences
- Objects can take up a large amount of memory
What are the features of the procedural programming paradigm?
- Uses built-in data types
- Uses built-in data structures
- Sequential
What are the advantages of the procedural programming paradigm?
- Good for general-purpose programming
- Lots of references are available
- No need to know precise CPU details
- Source code is portable
What are the disadvantages of the procedural programming paradigm?
- Many different types of languages, meaning you need to specialise
- Need to be precise and knowledgeable about the language, meaning debugging and coding can take a while
What are the features of the declarative programming paradigm?
- A programmer writes statements that specify the problem to be solved
- The software will seek an answer to a goal by interrogating a database with facts and rule
- Doesn’t function sequentially, so can backtrack while checking criteria
What are the two methods of parameter passing?
By value
By reference
Explain parameter passing by value
A local copy is created when passed
The original remains unchanged
Explain parameter passing by reference
The location of the data is passed
Changes will be made to the original data