A programming paradigmis a methodology or style for solving
problems using a specific programming language. Paradigms guide
how we structure and think about code, serving as fundamental
approaches to software development.
Procedural Programming
Focuses on procedures/functions that operate on
data. Uses a top-down approach where programs
are executed step-by-step in sequence.
Object-Oriented Programming
Organizes code into objects that contain both
data and behavior. Promotes concepts like
encapsulation, inheritance, and polymorphism.
Functional Programming
Treats computation as the evaluation of
mathematical functions. Emphasizes immutable
data and expressions over statements that
change state.
Introduction:
What Are
Programming
Paradigms?
4.
Core Concepts
Top-down approachto problem solving
Functions and data are separate entities
Sequential execution of statements
Focus on "how to achieve" rather than "what to
achieve"
Key Features
Modularity through functions
Local and global variable scope
Parameter passing mechanisms
Built-in functions library
Code reusability via procedures
Examples
C: Created by Dennis Ritchie (1972)
Pascal: Designed by Niklaus Wirth (1970)
FORTRAN: For scientific computing
COBOL: For business applications
/* Simple C function example */ int
calculate_sum(int a, int b) { return a +
b; }
Programming Paradigms
Procedural Programming
A programming paradigm based on the concept of procedure calls, where programs are structured as sequences of procedures operating on data.
5.
Object-Oriented
Programming (OOP)
Features andPrinciples
Definition
A programming paradigm based on the concept of "objects" that contain
data and code. Objects bundle data (attributes) and procedures (methods)
that work on that data.
Encapsulation
Bundling data and methods that operate on that data within a single unit
(class), and restricting access to some of the object's components. This
prevents external code from directly manipulating an object's internal
state.
Inheritance
Mechanism where a new class (child) derives or inherits the properties and
behaviors from another class (parent), allowing for code reuse and establishing
relationships between different classes.
Polymorphism
Ability of different objects to respond to the same method call in different
ways. It allows objects of different classes to be treated as objects of a
common superclass, enabling flexibility and extensibility.
Abstraction
Simplification of complex reality by modeling classes based on the essential
properties and behaviors, while hiding unnecessary details. Allows focusing
on what an object does instead of how it does it.
6.
Procedural
vs OOOP:
Key
Differences
Structure
How codeis organized
Procedural: Based on procedures or
functions that operate on data
OOP: Based on objects that contain both
data and methods
Data Handling
How data is managed
Procedural: Data can be accessed globally
and modified by any function
OOP: Data is encapsulated within objects
and accessed via methods
Reusability
How code is reused
Procedural: Functions can be reused but
may require passing the same data
OOP: Classes can be extended through
inheritance to reuse and enhance
functionality
Security
How data is protected
Procedural: Limited data protection; mostly
relies on careful programming
OOP: Data hiding through access modifiers
(private, protected, public)
Programming Paradigms
7.
Advantages & Disadvantages
ProceduralProgramming
Advantages:
Simple to implement and
understand.
Faster execution for
simple tasks.
Efficient memory usage
for small programs.
Disadvantages:
Difficult to maintain in large
programs.
Limited data security
(can’t hide data).
Code reuse requires duplicating
functions.
Object-Oriented
Programming
Advantages:
Data security through
hiding data.
Code reusability through
inheritance.
Natural modeling of real-world
entities.
Disadvantages:
Steeper learning curve for
beginners
Potential performance
overhead
Over-engineering for simple
problems
Selection Considerations
Choose Procedural When:
Building simple, small-scale
applications
Performance-critical
systems
Mathematical or algorithmic
focus
Choose OOP When:
Large, complex software
systems
Team-based development
projects
GUI applications and
games
8.
Real-Life Analogy:
Procedural vsOOP
Procedural Programming
Like following a recipe step-by-step where you
have ingredients (data) and explicit cooking
instructions (functions) kept separately. You
follow each procedure in sequence to
complete the dish.
Object-Oriented
Programming
Like kitchen appliances (objects) with their own
capabilities (methods) and states (properties).
Each appliance knows how to operate itself
and maintains its own internal state.
Making It Practical
In procedural, you call functions on data:
cook(ingredients). In OOP, objects perform
actions themselves: microwave.heat() or
blender.mix(). The latter is more intuitive for
complex systems that model real-world
interactions.
9.
Conclusion:
When to
Use
Which?
Use ProceduralWhen...
•Building small to medium-
sized applications.
•Performance is critical
(resource- limited environments).
•Solving mathematically
intensive problems.
•Simple data transformations are
the focus.
Use OOP When...
• Developing large, complex systems.
• Creating GUI applications.
•Working with teams on
collaborative projects.
•Modeling real-world entities
and relationships.
Decision Criteria
Consider project scale, team
expertise, maintainability
requirements, and whether problem
domain naturally fits into objects or
processes when choosing your
programming approach, architectural
pattern, or development methodology.
Hybrid Approach
Modern software often combines
paradigms strategically. Many languages
support multi-paradigm development,
allowing you to use procedural techniques
within object-oriented frameworks,
functional programming principles in
specific modules, or event-driven
programming for user interfaces.