A design pattern is a reusable, named solution to a commonly occurring problem in software design, described at a level of abstraction independent of any particular programming language. Design patterns capture proven architectural knowledge and improve communication between developers by providing a shared vocabulary. Popularised by the "Gang of Four" (Gamma, Helm, Johnson, Vlissides) in their 1994 book, patterns are categorised as creational, structural, or behavioural based on their intent.
| Category | Pattern Name | Intent | Example Use Case |
|---|---|---|---|
| Creational | Singleton | Ensure only one instance exists | Database connection pool |
| Creational | Factory Method | Delegate instantiation to subclasses | UI widget creation |
| Structural | Adapter | Convert interface to another | Legacy API wrapping |
| Structural | Decorator | Add behaviour without subclassing | Middleware pipelines |
| Behavioural | Observer | Notify dependents of state changes | Event listeners, MVC |
| Behavioural | Strategy | Encapsulate interchangeable algorithms | Sorting, payment gateways |
Wikimedia Commons, CC BY-SA
Functional programming (FP) is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state or mutable data. Core principles include pure functions (same input always yields same output, no side effects), immutability, first-class and higher-order functions, and function composition. FP promotes code that is predictable, testable, and parallelisable, and is embodied in languages such as Haskell, Erlang, Clojure, and adopted extensively in Scala, F#, and modern JavaScript/Python.
Object-Oriented Programming (OOP) is a programming paradigm that organises software design around data, called objects, rather than functions and logic. Each object encapsulates data (attributes) and behaviour (methods), and objects interact with one another to build complex systems. The four core principles of OOP — encapsulation, inheritance, polymorphism, and abstraction — promote code reusability, modularity, and maintainability.
The concept was adapted from architect Christopher Alexander's "pattern language" (1977). Erich Gamma and colleagues applied it to software in "Design Patterns: Elements of Reusable Object-Oriented Software" (1994), cementing the term in computer science.