Programming Paradigms
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Introduction
• Paradigm - Method to solve some problem or do some task.
• Programming paradigm - Way or approach to classifying
programming languages based on their features, patterns, coding
styles, frameworks, etc., to solve a particular problem.
• Divided into two broad categories.
✔ Imperative programming paradigm(how to do)
✔ Declarative programming paradigm(what to do)
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Imperative programming paradigm
• One of the oldest programming paradigm.
• Imperative programming consists of sets of detailed instructions that
are given to the computer to execute in a given order.
• Focuses on describing how a program operates, step by step.
• Also referred to as algorithmic programming.
• Example: C, C++, Java, Python
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Imperative programming paradigm
Advantages
• Very simple to implement.
• Contains loops, variables etc.,
Disadvantages
• Complex problem cannot be solved.
• Less efficient and less productive.
• Parallel programming is not possible.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Procedural Programming paradigm
• A type of imperative programming where a program is coded using
one or more functions or procedures.
• Derived from structured programming that is based on the concept of
procedures, also called subroutines, routines, and functions.
• Emphasizes a step-by-step sequence of instructions to perform a task.
• Example: C and Pascal.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Procedural Programming paradigm
Advantages:
• Emphasizes code reusability through the use of functions.
• Modular structure → easier debugging and testing.
Disadvantages:
• Hard to model real-world entities.
• Functions and data are separate, making large systems harder to
manage.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Structured Programming paradigm
• Emphasizes a clear, logical structure in programs by using control
structures such as:
✔ Sequence → execute statements one after another.
✔ Selection → decision-making (e.g., if-else, switch).
✔ Iteration → loops (e.g., for, while, do-while).
• Involves building of programs using small modules. Modules are easy
to read and write.
• Also known as Modular Programming.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Structured Programming paradigm
Advantages:
• Easier to read, debug, and maintain.
• Promotes code reuse through modules/functions.
• Reduces errors by following a logical flow.
• Provides a foundation for procedural programming and later OOP.
Disadvantages:
• Not ideal for very complex systems.
• Less flexible.
• Can still get bulky if not modularized properly.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Object Oriented Programming paradigm
• Revolves around the concept of objects, which are instances of
classes.
• It organizes code into objects that encapsulate data and behavior.
• OOP promotes modularity, reusability, and allows for concepts such
as inheritance, polymorphism, and encapsulation.
• Examples: Java, C++, and Python.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Object Oriented Programming paradigm
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Object Oriented Programming paradigm
Classes: Objects:
✔ A user-defined blueprint or ✔ A basic unit of Object-Oriented
prototype from which objects are Programming that represents
created. real-life entities.
✔ Represents the set of properties or ✔ Instance of a class.
methods that are common to all ✔ Stores data and set of functions that
objects of one type. can access the data.
✔ A collection of objects of similar
type.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Object Oriented Programming paradigm
Encapsulation:
✔ Wrapping up of data and functions in to a single unit.
✔ Data is not accessible to the outside world and only those functions
which are wrapped in the class can access it.
✔ Insulation of data from the direct access by the program-Data
hiding or Information hiding.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Object Oriented Programming paradigm
Abstraction:
✔ Act of representing essential features without including the
background details or explanations.
✔ Classes use the concept of abstraction.
✔ Attributes are sometimes called data members because they hold
information.
✔ Functions that operate on these data are called member functions.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Object Oriented Programming paradigm
Inheritance:
✔ The process by which objects of one class acquire the properties of
objects of another class.
✔ Provides the idea of reusability.
✔ Types:
Single inheritance,
Multiple inheritance,
Multilevel inheritance and
Hierarchical inheritance.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Object Oriented Programming paradigm
Polymorphism:
✔ The ability to take more than one form.
✔ The concepts of polymorphism are
Operator overloading - Process of making an operator to exhibit different
behaviors in different instances.
Function overloading - Use a single function to perform different tasks.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Declarative Paradigm
• A style of building programs that expresses logic of computation
without talking about its control flow.
• Focus is on what needs to be done rather how it should be done.
• Divided as
✔ Functional programming paradigms,
✔ Logic programming paradigms, and
✔ Database programming paradigms.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Functional Programming paradigm
• Execution of series of mathematical functions.
• Function which are meant for some specific computation and not the
data structure.
• Function can be replaced with their values without changing the
meaning of the program.
• Example: Perl, java script.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Logic Programming paradigm
• Based on formal logic; you define what the problem is, not how to solve
it.
• Uses a set of rules and facts, to describe constraints and relationships
within a problem domain
• Solve logical problems like puzzles, series etc.
• Execution of the program is very much like proof of mathematical
statement.
• Examples: Prolog
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Database Programming paradigm
• Heart of a business information system and provides file creation, data
entry, update, query and reporting functions.
• Example: SQL-Structured Query Language.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech
Other Types
Event Driven Programming
• Flow of the program is determined by events(user actions, sensor
outputs, messages).
• Examples: JavaScript, Visual Basic, GUI frameworks.
Parallel & Concurrent Programming:
• Programs are designed to execute multiple tasks simultaneously.
• Examples: Go, Java multithreading.
Prepared by [Link] Balaji, AP([Link]/CSE),PSGiTech