Programming Paradigm


A programming paradigm is a fundamental style or approach to programming that dictates how tasks should be structured and executed in each programming language.

  • encompasses principles, concepts, and patterns that guide the design and organization of code

Common Paradigms

  1. Imperative/procedural programming
    • focuses on describing a sequence of steps to perform a task
  2. Object-oriented programming (OOP)
    • organizes code around objects, which encapsulate data and behavior
  3. Functional programming
    • emphasizes the use of functions and immutable data for computation
  4. Declarative programming
    • describes what the program should accomplish without specifying how to achieve it
  5. Event-driven programming
    • reacts to events and user actions, triggering corresponding functions
  6. Logic programming
    • defines a set of logical conditions and lets the system deduce solutions
  • paradigms are often combined to create efficient, modular, and maintainable code

Procedural Programming

Procedural programming is a programming paradigm that focuses on procedures or routines.

  • structures codes as a series of steps
  • emphasizes a linear flow of execution
  • variables store data
  • functions manipulate data
  • top-down
  • lacks encapsulation and abstraction
  • good for simple tasks
  • complex for larger projects

Object-oriented Programming (OOP)

Object-oriented programming (OOP) is a programming paradigm centered on objects, encapsulating data and methods that operate on data.

  • enhances code organization and reusability
  • models real-world entities as objects with attributes as behaviors
  • key principles:
    • encapsulation
      • ensures data privacy
    • inheritance
      • facilitates code reuse
    • polymorphism
      • enables flexibility
  • simplifies complex systems
    • modular and scalable code design