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
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 PUBLICPROCEDURE SetName(n : STRING)
name ← n ENDPROCEDURE PUBLICFUNCTION GetName() RETURNS STRING RETURN name ENDFUNCTION ENDCLASS
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
Paradigm
Focus
Key idea
Example languages
Procedural
HOW (step by step)
Sequences, procedures, loops
Pascal, C, Python (procedural style)
Object-Oriented
OBJECTS (data + behaviour)
Classes, encapsulation, inheritance
Java, C++, Python (OOP style)
Functional
FUNCTIONS (pure, no side effects)
Immutable data, higher-order functions
Haskell, F#, Erlang
Declarative
WHAT (not how)
State the goal; system finds the path
SQL, 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!
Term
Definition
🎯
Mini Test — 2.5.1 Programming Paradigms
10 questions · 10 marks · 10 minutes
⏱ 10:00
Section A — Multiple Choice [5 marks]
Q1Which paradigm is characterised by specifying WHAT the result should be rather than HOW to compute it?
Q2What is a 'pure function' in functional programming?
Q3In OOP, what is the term for bundling data and methods together and hiding internal implementation details?
Q4SQL (Structured Query Language) is an example of which paradigm?
Q5Which of the following best describes procedural programming?
Section B — Short Answer [5 marks]
Q6Explain what 'immutability' means in functional programming and why it is useful.
Mark schemeImmutability means data values do not change after they are created [1]; instead of modifying existing data, functional programs create new values [1]; this makes programs easier to reason about (no unexpected side effects) and simplifies debugging since no variable unexpectedly changes value [1].
Q7State two differences between a CLASS and an OBJECT in OOP.
Mark schemeA class is a template/blueprint; an object is a specific instance created from that class [1]; a class defines what attributes and methods objects of that type have; objects hold the actual data values for those attributes [1]; multiple objects can be created from one class, each with different attribute values [1]. (2 marks max)
Q8Give one example of a declarative language and explain what makes it declarative.
Mark schemeSQL (or Prolog) [1]; declarative because the programmer specifies WHAT data is required (e.g. SELECT name FROM students WHERE grade='A') without specifying how the database should locate or iterate through the records — the engine determines the execution plan [1].
Q9What does 'first-class function' mean in functional programming? Give an example of how it might be used.
Mark schemeA first-class function is one that can be treated like any other value — stored in a variable, passed as an argument to another function, or returned from a function [1]; example: passing a comparison function to a sort function, or passing a filter condition to a map/filter function, e.g. filter(isEven, myList) where isEven is a function passed as an argument [1].
Q10State two features that distinguish OOP from procedural programming.
Mark schemeAny two: OOP bundles data and methods together in objects (encapsulation); procedural keeps data and functions separate [1]; OOP uses inheritance — subclasses can inherit attributes/methods from superclasses; procedural has no class hierarchy [1]; OOP uses polymorphism — same method name on different objects can behave differently [1]; OOP uses classes as templates for objects; procedural uses procedures/functions that act on separate variables [1].