Photo AI
Last Updated Sep 27, 2025
Revision notes with simplified explanations to understand Programming Paradigms quickly and effectively.
246+ students studying
Programming paradigms are different approaches or styles of programming, each with unique principles and techniques for structuring code. Each paradigm has specific strengths and weaknesses, making it more suitable for particular types of problems or programming scenarios. Understanding these paradigms helps programmers choose the right tool for the job, enhancing code quality, maintainability, and efficiency.
Paradigm | Strengths | Weaknesses | Ideal For |
---|---|---|---|
Procedural | Simple, structured | Limited reusability, less modular | Linear and simple data processing tasks |
Object-Oriented | Modular, reusable | Complex for small projects, memory usage | Large-scale applications, GUIs, games |
Low-Level | High performance, control over hardware | Complex, error-prone, poor portability | Embedded systems, OS development |
Functional | Easy debugging, concurrency-friendly | Learning curve, potential performance cost | Concurrent applications, data analysis |
Event-Driven | Ideal for interactive applications | Complex event handling, higher resource use | GUIs, mobile and web applications |
Object-Oriented Programming organises code around "objects" rather than actions. An object is an instance of a class, which is a blueprint for creating objects with specific properties (attributes) and behaviours (methods). Key OOP principles include Encapsulation, Inheritance, Polymorphism, and Abstraction.
Example: Modeling Animals in OOP
numberOfLegs
(integer), isMammal
(boolean)// Base class
public class Animal {
private int numberOfLegs;
private boolean isMammal;
// Method to simulate making a sound
public void makeSound() {
System.out.println("I'm making a sound");
}
// Getter for number of legs (Encapsulation)
public int getNumberOfLegs() {
return numberOfLegs;
}
}
// Subclass demonstrating Inheritance
public class Dog extends Animal {
private String breed;
private String name;
// Unique method for Dog class
public void fetch() {
System.out.println("I caught the ball!");
}
// Overriding makeSound method for Dog
@Override
public void makeSound() {
System.out.println("Woof woof");
}
}
// Demonstration of Polymorphism and object creation
public static void main(String[] args) {
Animal cow = new Animal();
Dog spot = new Dog();
// Calling methods
cow.makeSound(); // Output: "I'm making a sound"
spot.makeSound(); // Output: "Woof woof" (overridden)
// Demonstrating Polymorphism
Animal rex = new Dog();
rex.makeSound(); // Output: "Woof woof"
}
Methods: makeSound()
numberOfLegs
are private, and accessible only through getter methods.Dog
class inherits from Animal
, gaining its attributes and methods.rex
is declared as an Animal
but instantiated as a Dog
, allowing it to use overridden methods.Procedural programming structures code around procedures or functions, creating a clear flow of instructions. It emphasises sequential execution and is well-suited for tasks with a logical flow.
Example: Calculating Factorial
# Procedural approach to calculate the factorial of a number
def factorial(n):
result = 1
for i in range(1, n + 1):
result *= i
return result
# Example usage
print(factorial(5)) # Output: 120
In this example:
factorial
function is a self-contained block that takes an input n
and returns n!
.Low-level programming operates close to the hardware, providing direct control over memory and processing. This paradigm often uses Assembly Language or low-level languages like C, making it suitable for performance-critical tasks.
Example: Assembly Code for Adding Two Numbers (x86 Syntax)
section .data
num1 db 5 ; Define a byte with value 5
num2 db 10 ; Define a byte with value 10
result db 0 ; Define a byte to store the result
section .text
global _start
_start:
mov al, [num1] ; Load num1 into register AL
add al, [num2] ; Add num2 to the value in AL
mov [result], al ; Store the result in 'result'
; Exit the program (Linux system call)
mov eax, 1
int 0x80
In this example:
mov
and add
instructions control the CPU registers directly for high efficiency.Functional programming treats computation as the evaluation of mathematical functions, avoiding changing state and mutable data. It emphasises pure functions, immutability, and first-class functions.
Example: Recursive Function for Calculating Fibonacci Numbers (in Haskell)
-- Function to calculate nth Fibonacci number using recursion
fibonacci :: Int -> Int
fibonacci 0 = 0
fibonacci 1 = 1
fibonacci n = fibonacci (n - 1) + fibonacci (n - 2)
-- Usage example
main = print (fibonacci 10) -- Output: 55
In this example:
fibonacci
only depends on its input and does not alter any external state.Paradigm | Characteristics | Example |
---|---|---|
Object-Oriented Programming | Organises code around objects with attributes and behaviors | Java class Animal with subclass Dog demonstrating inheritance, encapsulation, and polymorphism |
Procedural Programming | Structured around functions and procedures | Python function factorial for sequentially calculating a number's factorial |
Low-Level Programming | Direct control over hardware and memory | Assembly code snippet for adding two numbers using registers |
Functional Programming | Treats computation as function evaluation, with immutability | Haskell recursive function fibonacci for calculating Fibonacci numbers |
Enhance your understanding with flashcards, quizzes, and exams—designed to help you grasp key concepts, reinforce learning, and master any topic with confidence!
40 flashcards
Flashcards on Programming Paradigms
Revise key concepts with interactive flashcards.
Try Computer Science Flashcards4 quizzes
Quizzes on Programming Paradigms
Test your knowledge with fun and engaging quizzes.
Try Computer Science Quizzes29 questions
Exam questions on Programming Paradigms
Boost your confidence with real exam questions.
Try Computer Science Questions27 exams created
Exam Builder on Programming Paradigms
Create custom exams across topics for better practice!
Try Computer Science exam builder12 papers
Past Papers on Programming Paradigms
Practice past papers to reinforce exam experience.
Try Computer Science Past PapersDiscover More Revision Notes Related to Programming Paradigms to Deepen Your Understanding and Improve Your Mastery
96%
114 rated
Types of Programming Language
Assembly Language & Little Man Computer
411+ studying
185KViewsJoin 500,000+ A-Level students using SimpleStudy...
Join Thousands of A-Level Students Using SimpleStudy to Learn Smarter, Stay Organized, and Boost Their Grades with Confidence!
Report Improved Results
Recommend to friends
Students Supported
Questions answered