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
- Imperative/procedural programming
- focuses on describing a sequence of steps to perform a task
- Object-oriented programming (OOP)
- organizes code around objects, which encapsulate data and behavior
- Functional programming
- emphasizes the use of functions and immutable data for computation
- Declarative programming
- describes what the program should accomplish without specifying how to achieve it
- Event-driven programming
- reacts to events and user actions, triggering corresponding functions
- 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
- encapsulation
- simplifies complex systems
- modular and scalable code design