Chapter 13 - Programming Paradigms
List the 3 main programming paradigms
1. Procedural (Imperative)
2. Object-Oriented
3. Declarative (includes functional and logic styles – awareness level)
Chapter 13 - Programming Paradigms
What are some key characteristics of the Procedural Paradigm
Key characteristics:
- Program follows sequence -> selection -> iteration
- Uses procedures and functions
- Data stored in variables that change
- Top-down design (break problem into smaller steps)
- Easy to trace because control flow is visible
- Ideal for mathematical or algorithmic problems
Chapter 13 - Programming Paradigms
What are some benefits and drawbacks of using the Procedural Paradigm
Advantages:
- Simple to write and understand
- Efficient and fast
- Works well for algorithms
- Each subroutine can be tested on its own
Disadvantages:
- Not suitable for large sysems with many interacting parts
- No built-in way to protect data (no encapsualtion)
- Data and operations are separate, cause duplication
- Harder to maintain as system grows
Suitables for:
- Problems with a clear sequence of actions
- Programs where data noes not need complex structure
- Situations where speed and low overhead matter
Chapter 13 - Programming Paradigms
What are some real examples of procedural tasks
Chapter 13 - Programming Paradigms
What are some key characteristics of the Object-Oriented Paradigm
Key characteristics:
- Classes define attributes and methods
- Objects represent real-world things
- Encapsulations protects internal data
- Inheritance shares common behaviour
- Polymorphism allows flexible method behaviour
- Ideal for large systems with many related entities
Chapter 13 - Programming Paradigms
What are some benefits and drawbacks of using the Object-Oriened Paradigm
Advantages:
- Encapsulation protects data
- Inheritance reduces repeated code
- Polymorphism gives flexibility
- Easier to maintain and scale
- Mirrors real-world systems
Disadvantages:
- More complex to learn
- More memory overhead
- Not ideal for simple algorithms
- Overuse of classes can overcomplicate solutions
Suitables for:
- Long-term, complex projects
- Systems where many entities interact
- Projects requiring maintainability and extension
- Scenarios where data protection is needed
Chapter 13 - Programming Paradigms
What are some real OOP examples
Chapter 13 - Programming Paradigms
What are some key characteristics of the Declarative Paradigm
Two sub-types:
- Functional – Programs are built from pure functions without side effects
- Logic – Program consist of facts and rules, and the system works out answers
Functional: Key characteristics:
- No changing state
- No loops (recursion is used instead)
- Functions take inputs and produce outputs
- Easy to test because results depend only on inputs
Logic: Key characteristics:
- You state logical relationships
- The interpreter performs inference
- No explicit control flow
Chapter 14 - Assembly Language
Explain the 4 different addressing modes
1. Immediate addressing - the operand is the actual value to be operated on
2. Direct addressing - the operand holds the memory address of the value to be operated on. This is the only addressing mode used in the LMC assembly language
3. Indirect addressing - the operand is the location which holds the address of the data we want. This enables a larger range of addressable locations
4. Indexed addressing - the address of the operand is obtained by adding the contents of the index register a constant value ( usually 1 ). The number of the index register and the constant value are included in the instruction code.