Addis Ababa University
College of natural and computational sciences
Department of Information Science
Section 1
Computer programming
Group Assignment – Programming Paradigms
Rekik Girma……………………………………………………UGR/9167/16
Haileyesus Gizaw…………………………………………..UGR/6604/16
Submitted to: Mr. Teshome Alemu
Submission date: 25/05/2024 G.C.
i
Table of contents
1. Programming Paradigm definition.……………………………………………….1
2. Imperative programming……………….…………………………………………….1
3. Procedural programming……………………………………………………………..1
4. Object-oriented programming……………………………………………………….2
5. Declarative programming……………………………………………………………..3
6. Functional programming………………………………………………………………3
7. Event-driven programming……………………………………………………………4
8. References…………………………………………………………………………………..5
ii
What is a programming paradigm?
A programming paradigm is a fundamental style or approach to building software. Different
programming paradigms offer distinct ways of thinking about and solving problems, each
with its own strengths and weaknesses. Programming paradigms can be branched out from
imperative and declarative programming paradigms. Here are some of the major
programming paradigms.
Imperative Programming
Imperative programming is a paradigm where every operation required to solve a problem is
explicitly coded, focusing on how to solve the problem with detailed step-by-step instructions.
This programming paradigm specifies the exact sequence of commands and state changes
rather than high-level descriptions of its expected results. This paradigm includes procedural
and object-oriented programming languages like C+, C++, c#, and Java.
It’s characterized by: 1) Sequence of commands: instructions executed in a specific order.
2) State Changes: variables’ values change over time.
3) Control Structures: uses loops & conditionals to manage execution flow.
Imperative programming is known for its simplicity and readability for sequential tasks. It also
provides us with fine-grained control over execution, allowing performance optimization. Albeit
these benefits it also comes with its own set of disadvantages like complexity issues as the
program increases in scale and challenges in explicit state management and side effects.
Imperative programming offers direct control over computer operations, providing a solid
foundation for many applications, but can become complex as systems grow.
Procedural Programming
Procedural programming is a programming paradigm built around the idea that programs are
sequences of instructions to be executed. They focus heavily on splitting up programs into
named sets of instructions called procedures, analogous to functions. Procedural programming
a type of imperative programming, structures a program into procedures or functions,
enhancing modularity and code organization.
It has characteristics that enable it to have certain advantages. These are:
Modularity: Programs are divided into procedures or functions, promoting code reuse
and simplifying maintenance.
Imperative Nature: Program statements are executed sequentially, following the order
of procedure calls.
State Management: Local variables within procedures encapsulate the state,
maintaining data integrity.
Parameter Passing: Procedures can accept parameters, enabling them to operate on
different data sets.
Structured Approach: Follows principles of structured programming, emphasizing
clarity and maintainability.
Procedural programming is reusable, modular, and maintainable meaning functions can be used
across different parts of the program, divide programs into functions thus simplifying
management and comprehension and its functions encapsulate specific tasks, making
debugging and updates easier. On the backside large programs can become complex with too
many interdependent functions, making it hard to track the flow of execution.
Overall, procedural programming in languages like C++ enhances code organization and
modularity through the use of functions. Despite potential complexity and performance
overhead in large programs, it remains fundamental for creating structured and manageable
software systems, promoting reusability, maintainability, and comprehension.
Object-oriented programming
Object-oriented programming (OOP) is a programming paradigm centered around the concept
of "objects," which are instances of classes that encapsulate data (attributes) and behavior
(methods). It emphasizes the organization of code into objects rather than functions and logic.
Characteristics:
Classes and Objects: Programs are organized into classes, which serve as blueprints for
creating objects.
Inheritance: Classes can inherit attributes and behavior from other classes, promoting
code reuse and hierarchy.
Encapsulation: Objects encapsulate their state and behavior, hiding internal
implementation details and exposing only necessary interfaces.
Polymorphism: Objects of different classes can be treated uniformly through
polymorphism, allowing methods to behave differently based on the object's type.
Object-oriented programming is known for its encapsulation and abstraction that facilitate
modular design, making code easier to understand, maintain, and extend. Inheritance and
polymorphism enable code reuse, reducing redundancy and promoting efficiency. OOP also
supports dynamic binding allowing for flexible and extensible designs.
Object-oriented programming provides a powerful paradigm for organizing and managing
complex software systems. By encapsulating data and behavior into objects, OOP promotes
modularity, reusability, and maintainability. While it introduces complexities and potential
performance overhead, its benefits in terms of code organization and scalability make it a widely
adopted paradigm in modern software development. Understanding OOP principles is essential
for building robust and maintainable software applications.
Declarative programming
Declarative programming is a programming paradigm where programs are constructed by
specifying what should be achieved rather than how to achieve it. It focuses on expressing the
logic of a computation without describing its control flow explicitly. Declarative models rely on
preconfigured capabilities in the language without explicit case-by-case instructions on what
steps to take to accomplish a particular task. The declarative programming paradigm includes
functional programming.
Declarative programming focuses on expressing intent rather than implementation details
enhancing code clarity. It facilitates easier modification and maintenance of code. Declarative
programming also integrates logic into reusable functions promoting code abstraction and
reusability.
Declarative programming offers a paradigm where programs are structured around expressing
the problem domain rather than procedural steps. It promotes clarity, modifiability, and
abstraction, facilitating the development of more maintainable and reusable code. However, it
may require developers to adapt to its different approach and may introduce performance
considerations depending on implementation details.
Functional programming
Functional programming is a declarative programming paradigm style (expresses the logic of a
computation without describing its control flow) where one applies pure functions in sequence
to solve complex problems. Functions take an input value and produce an output value without
being affected by the program. This programming paradigm treats computation as the
evaluation of mathematical functions and avoids changing state and mutable data. It
emphasizes the use of pure functions, immutability, and higher-order functions, leading to more
predictable and maintainable code.
Characteristics:
Declarative Nature: Programs are constructed by applying and composing functions,
rather than using imperative statements.
First-Class Functions: Functions are treated as first-class citizens, allowing them to be
passed as arguments, returned from other functions, and assigned to variables.
Modular and Composable: Small functions are combined in a modular manner,
promoting code reusability and maintainability.
Functional programming is predictable, maintainable, and concurrent (Reduced risk of race
conditions in concurrent programs due to immutability). On the downside, it has disadvantages
like performance overhead and concepts like higher-order functions can be challenging.
Functional programming in C++ utilizes features like lambda expressions and higher-order
functions to enhance code predictability and maintainability. While C++ is not purely functional,
it supports functional programming concepts beneficially. By emphasizing pure functions and
immutability, functional programming reduces bugs and enhances program understandability.
Additionally, in computer science, functional programming treats programs as compositions of
functions rather than sequences of imperative statements. It offers benefits like reduced bugs,
easier debugging, testing, and formal verification. While historically less popular than imperative
programming, functional languages are increasingly used in industry and education,
demonstrating their relevance and applicability across various domains.
Event-driven Programming
Event-driven programming is a programming paradigm in which the flow of the program is
determined by external events. It is a programming paradigm where the flow of the program is
determined by events such as user actions, sensor outputs, or messages from other programs.
The program responds to these events by executing predefined event handlers or callback
functions.
Characteristics:
Asynchronous Execution: Programs are designed to respond to events not at the same
time, allowing for concurrent execution of event handlers.
Event Loop: Central to event-driven programming, an event loop continuously listens
for events and dispatches them to appropriate handlers.
Event Handlers: Functions or procedures defined to handle specific events, triggered
when the corresponding event occurs.
Callback Functions: Functions passed as arguments to other functions to be executed
later, commonly used as event handlers.
Event-driven programs are highly responsive as they react promptly to external stimuli. Event-
driven programming allows for an efficient utilization of system resources and their decoupling
of event handlers promotes modularity and code reuse. Debugging event-driven programs can
be challenging due to the asynchronous nature of event handling.
Event-driven programming offers a flexible and responsive approach to developing software
systems, particularly suitable for applications requiring real-time interactions or handling
multiple concurrent activities. While it enhances responsiveness and scalability, it may introduce
complexity and debugging challenges. Understanding event-driven paradigms and effectively
managing event flow is crucial for developing robust event-driven applications.
References;
o https://www.techtarget.com/whatis/
o https://en.m.wikipedia.org/wiki/Computer_science
o https://en.m.wikipedia.org/wiki/Computer_programming
o https://www.turing.com/kb/introduction-to-functional-programming