- Programming Paradigms โ Paradigm Examples for Beginners (freeCodeCamp): The ideal conceptual starting point. It breaks down the philosophical difference between the Imperative Mindset (how to do something) and the Declarative Mindset (what to achieve).
- Functional Programming for the OO Developer (Dev.to): Focuses heavily on the mathematical definitions of a function (inputs mapping strictly to outputs) versus how traditional Object-Oriented programming handles data.
- Structure and Interpretation of Computer Programs - SICP (MIT/Berkeley Lectures): Widely considered the "wizard book" of computer science. It skips language-specific syntax to focus entirely on the grand theory of abstraction, state, and programming paradigms.
- Programming Paradigms for Dummies (PDF): A rigorous, academic look at software computation models. It provides a taxonomy of paradigms based on how they handle state, threads, and closures
The best way to understand theory is to build the exact same project three different ways. The following lightweight projects can easily be adapted across all three paradigms:
- Procedural Approach: Create a global variable or dictionary representing the wallet. Write sequential functions like deposit(amount) and withdraw(amount) that directly mutate that global variable.
- OOP Approach: Create a BankAccount class. Encapsulate the balance as a private property. Use methods like account.deposit() to alter the internal state of individual object instances.
- Functional Approach: Keep the state entirely immutable. Write pure functions that take a currentBalance and an amount as arguments, returning a completely new balance integer without altering the original variables.
- Procedural Approach: Use nested loops, if/else statements, and global flags to move a player sequentially through rooms.
- OOP Approach: Create Room, Player, and Item classes. Use polymorphism so different types of rooms or items react uniquely when interacted with.
- Functional Approach: Treat the entire game state as a single data structure. Use pure functions and recursion to pass the old game state into a function and output a new, updated game state slice based on user choice.
- Procedural Approach: Use a for loop to step through a raw dataset line by line, appending passing items to a new list manually.
- OOP Approach: Create a DataStream or Dataset class with internal methods to load, filter, and transform data objects.
- Functional Approach: Use chained higher-order functions like map(), filter(), and reduce() to pipe raw data through transformations without ever mutating the source data array.