🔢 Paper 2 · 2.5 Programming Paradigms
2.5.1 Programming Paradigms — Procedural, OOP, Functional & Declarative
Cambridge 9618 · International A Level Computer Science · Free Lesson · ~14 min read
Notes
Video
Slides
Quiz
Worksheet

What is a Programming Paradigm?

A programming paradigm is a fundamental style or approach to programming that defines how programmers structure and write code. Different paradigms provide different mental models for solving problems.

Cambridge 9618 covers four paradigms:

⚙️
Procedural
Sequential / Imperative
Programs are sequences of instructions. Code is organised into procedures/functions. The programmer specifies HOW to solve the problem step by step.
📦
Object-Oriented
OOP
Programs are built from objects — instances of classes that bundle data (attributes) and behaviour (methods). Models real-world entities.
λ
Functional
Declarative / Mathematical
Programs are built from pure functions with no side effects. Functions are first-class values. Based on mathematical function evaluation.
📋
Declarative
What, not How
Programmer specifies WHAT the result should be, not HOW to compute it. The system works out the steps. SQL is declarative. Includes functional and logic programming.

Procedural Programming

Procedural programming is the foundation of Cambridge 9618 Paper 2 — all pseudocode you write is procedural. It uses sequences of instructions, conditional logic, loops, and subroutines.

Key Features of Procedural Programming

  • Sequence — instructions execute in order, one after another
  • Selection — IF...THEN...ELSE...ENDIF and CASE OF...ENDCASE
  • Iteration — FOR/NEXT, WHILE/ENDWHILE, REPEAT/UNTIL
  • Procedures and functions — reusable blocks of code; procedures: no return value; functions: return a value via RETURNS
  • Variables and constants — named storage locations (DECLARE, CONSTANT)
  • Top-down design — break a large problem into smaller sub-problems, each implemented as a procedure

Procedural Pseudocode Example

PROCEDURE PrintGrade(score : INTEGER)
  IF score >= 70 THEN
    OUTPUT "Grade A"
  ELSE
    IF score >= 50 THEN
      OUTPUT "Grade B"
    ELSE
      OUTPUT "Grade C"
    ENDIF
  ENDIF
ENDPROCEDURE

Object-Oriented Programming (OOP)

OOP organises code around objects — self-contained units that combine data and the operations that act on that data. OOP is covered in full detail in lesson 2.5.2.

Core OOP Concepts (Overview)

  • Class — a blueprint/template that defines the attributes and methods of a type of object
  • Object — an instance of a class; each object has its own values for the class's attributes
  • Encapsulation — bundling data and methods together; hiding internal details from outside code
  • Inheritance — a subclass inherits attributes and methods from a superclass, and can add new ones
  • Polymorphism — different objects can respond to the same method call in different ways

OOP Example (conceptual)

// Class definition
CLASS Animal
  PRIVATE name : STRING
  PUBLIC PROCEDURE SetName(n : STRING)
    name ← n
  ENDPROCEDURE
  PUBLIC FUNCTION GetName() RETURNS STRING
    RETURN name
  ENDFUNCTION
ENDCLASS

// Creating an object (instance)
DECLARE myAnimal : Animal
myAnimal.SetName("Lion")
OUTPUT myAnimal.GetName()

Functional Programming

Functional programming treats computation as the evaluation of mathematical functions. It avoids changing state and mutable data.

Key Features of Functional Programming

  • Pure functions — always return the same output for the same input; no side effects (don't modify variables outside themselves)
  • Immutability — data does not change; instead new values are created
  • First-class functions — functions can be passed as arguments to other functions, returned as values
  • Higher-order functions — functions that take other functions as parameters (e.g. map, filter, fold)
  • Recursion — used instead of loops for iteration

Examples of functional languages: Haskell, F#, ML. Many languages (Python, JavaScript) support functional features alongside other paradigms.

Declarative Programming

Declarative programming expresses what should be computed rather than how. The execution details are handled by the runtime system.

  • SQL — the most common declarative language for databases: SELECT name FROM students WHERE grade = 'A'
  • Logic programming — e.g. Prolog: you define facts and rules; the system deduces answers
  • Functional programming is also considered declarative (you describe what a function computes, not how the computer executes it step by step)

Comparing the Four Paradigms

ParadigmFocusKey ideaExample languages
ProceduralHOW (step by step)Sequences, procedures, loopsPascal, C, Python (procedural style)
Object-OrientedOBJECTS (data + behaviour)Classes, encapsulation, inheritanceJava, C++, Python (OOP style)
FunctionalFUNCTIONS (pure, no side effects)Immutable data, higher-order functionsHaskell, F#, Erlang
DeclarativeWHAT (not how)State the goal; system finds the pathSQL, Prolog, HTML/CSS
Cambridge 9618 exam focus: For Paper 2, you need to: (1) define each paradigm and give examples, (2) explain the difference between procedural and OOP, (3) explain features of functional programming (pure functions, immutability, first-class functions). Full OOP implementation is in lesson 2.5.2.
Procedural vs Declarative: In procedural you specify HOW to compute the result (the exact steps). In declarative you specify WHAT result you want (the goal). SQL example: you write SELECT ... WHERE ... and the database engine works out which rows to retrieve and in which order — you don't specify the algorithm.
⚠️ Common Mistakes
  • Saying OOP and procedural are opposites — both can exist in the same language (e.g. Python supports both)
  • Confusing declarative with functional — functional IS a type of declarative, but declarative also includes logic programming (Prolog) and SQL
  • Saying functional programs have no loops — functional programs use recursion instead of loops, not no iteration at all
  • Saying procedural programs cannot use functions — procedural programs use procedures and functions; the difference from OOP is that data and functions are separate (not bundled in classes)
✅ Notes completed!
Video coming soon
Click slide or press arrow keys to navigate

Worksheet — 2.5.1 Programming Paradigms

8 questions · Cambridge 9618 standard

Q1Define the term 'programming paradigm' and name the four paradigms required by Cambridge 9618.[3]
✅ Mark scheme
A programming paradigm is a fundamental style/approach to programming that defines how programmers structure and think about problems [1]; the four paradigms are: Procedural, Object-Oriented (OOP), Functional, and Declarative [2 — 1 mark for 2-3, 2 marks for all 4].
Q2State three features of procedural programming.[3]
✅ Mark scheme
Any three of: sequence (instructions execute in order) [1]; selection (IF/CASE) [1]; iteration (FOR/WHILE/REPEAT loops) [1]; procedures and functions (reusable named blocks of code) [1]; variables and constants to store data [1]; top-down design / stepwise refinement [1].
Q3Explain the difference between 'procedural' and 'declarative' programming with an example of each.[4]
✅ Mark scheme
Procedural: programmer specifies HOW to solve the problem — gives explicit step-by-step instructions [1]; example: pseudocode with FOR loops and IF statements [1]; Declarative: programmer specifies WHAT the result should be, not how to compute it — the system works out the steps [1]; example: SQL SELECT query — programmer states which data they want; the database engine decides how to retrieve it [1].
Q4State two key features of functional programming that distinguish it from procedural programming.[4]
✅ Mark scheme
Any two features with explanation: Pure functions — always return the same output for the same input; no side effects (don't modify external state) [1+1]; Immutability — data values do not change; instead new values are created [1+1]; First-class functions — functions can be passed as arguments to other functions [1+1]; Recursion instead of loops for iteration [1+1]. (4 marks = 2 features × [name + explanation])
Q5Describe what a 'class' and an 'object' are in OOP, and explain the relationship between them.[3]
✅ Mark scheme
A class is a blueprint/template that defines the attributes (data) and methods (operations) that objects of that type will have [1]; an object is a specific instance of a class — created from the class and having its own values for the attributes [1]; the class defines the structure, the object is a concrete realisation of that structure — you can create many objects from one class, each with different data [1].
Q6Give one advantage of OOP over procedural programming for large software projects.[2]
✅ Mark scheme
Any one with justification: Encapsulation hides internal data and exposes only a clean interface — reduces complexity and prevents unintended interference with data [2]; Reusability — classes can be reused across different parts of the program or in other projects through inheritance [2]; Easier to model real-world entities — complex systems can be represented as collections of interacting objects [2]. (2 marks = advantage [1] + reason/justification [1])
Q7Design a set of test data for a function that accepts a student's exam mark (0–100) and returns a grade (A, B, C, D, or F). Include at least one example of normal data, boundary data, and erroneous data. For each test, state the expected output and justify why that test is necessary.[6]
✅ Mark scheme
Normal data: e.g. 75 → B grade — 1 mark; boundary data: 0 → F (lower), 100 → A (upper) — 1 mark; boundary just inside: e.g. 70 → A or B depending on boundary — 1 mark; erroneous: -1 → error/rejection, 101 → error/rejection — 1 mark; justification for boundary: tests edge cases where off-by-one errors occur — 1 mark; justification for erroneous: ensures program rejects invalid inputs gracefully — 1 mark.
Q8Compare white-box testing and black-box testing. State one advantage of each approach and give a scenario where each would be used during software development.[4]
✅ Mark scheme
Black-box: tests based on specification/expected outputs, tester does not see code — 1 mark; advantage: tests from user perspective, catches missing requirements — 1 mark; White-box: tests based on internal code structure, all paths exercised — 1 mark; advantage: ensures all code branches are tested, catches unused paths — 1 mark. (Scenario marks may substitute for advantage marks if clearly linked.)
Topic Quiz
Question 1 of 10
You scored
out of 10
Card 1 of 8
Click to reveal definition
🎉
All cards reviewed!
TermDefinition
🎯

Mini Test — 2.5.1 Programming Paradigms

10 questions · 10 marks · 10 minutes

← 2.4.5 Big-O Notation
48 of 82 · Cambridge 9618
2.5.2 Object-Oriented Programming →