0% found this document useful (0 votes)
13 views7 pages

Overview of Programming Paradigms

The document discusses six different programming paradigms: object-oriented programming, imperative programming, structured programming, procedural programming, declarative programming, and functional programming. It provides details on features and characteristics of each paradigm.

Uploaded by

peaceissa695
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views7 pages

Overview of Programming Paradigms

The document discusses six different programming paradigms: object-oriented programming, imperative programming, structured programming, procedural programming, declarative programming, and functional programming. It provides details on features and characteristics of each paradigm.

Uploaded by

peaceissa695
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CAMPUS ; JKUAT –MAIN

COURSE ; ICS 2175 – COMPUTER PROGRAMMING I

DEPARTMENT; TIE

ASSIGNMENT

TYPES OF PROGRAMMING PARADIGMS

GROUP MEMBERS:

NAME REGISTRATION NO.

1 JOE GICHURU ISAAC ENE221-0096/2021

2 REDEMPTA MWANIKI ENE221-0109/2021

3 WALOBWA DAN ENE221-0180/2021

4 ESTHER WANGARI ENE221-0119/2021

5 MARRISSA MUTINDA ENE221-0118/2021

6 MARK GRIFFIN ENE221-0112/2021


TYPES OF PROGRAMMING PARADIGMS

1. OOP PROGRAMMING
Object-oriented programming (OOP) is a computer programming model that organizes
software design around data, or objects, rather than functions and logic. An object can be
defined as a data field that has unique attributes and [Link] focuses on the objects
that developers want to manipulate rather than the logic required to manipulate
[Link] PROGRAMMING

Principles( or features) of object oriented programming:


1. Encapsulation
2. Data abstraction.
3. Polymorphism
4. Inheritance
5. Dynamic binding
6. Message passing
Encapsulation:
Wrapping of data and functions together as a single unit is known as encapsulation.
By default data is not accessible to outside world and they are only accessible
through the functions which are wrapped in a class. prevention of data direct access
by the program is called data hiding or information hiding
Data abstraction :
Abstraction refers to the act of representing essential features without including the
back ground details or explanation. Classes use the concept of abstraction and are
defined as a list of attributes such as size, weight, cost and functions to operate on
these attributes. They encapsulate all essential properties of the object that are to be
created. The attributes are called as data members as they hold data and the functions
which operate on these data are called as member functions. Class use the concept of
data abstraction so they are called abstract data type (ADT)
Polymorphism:
Polymorphism comes from the Greek words “poly” and “morphism”. “poly” means
many and “morphism” means form i.e.. many forms. Polymorphism means the
ability to take more than one form. For example, an operation have different behavior
in different instances. The behavior depends upon the type of the data used in the
operation. Different ways to achieving polymorphism in C++ program: 1) Function
overloading 2) Operator overloading
Inheritance:
Inheritance is the process by which one object can acquire the properties of another.
Inheritance is the most promising concept of OOP, which helps realize the goal of
constructing software from reusable parts, rather than hand coding every system from
scratch. Inheritance not only supports reuse across systems, but also directly
facilitates extensibility within a system. Inheritance coupled with polymorphism and
dynamic binding minimizes the amount of existing code to be modified while
enhancing a system. When the class child, inherits the class parent, the class child is
referred to as derived class (sub class) and the class parent as a base class (super
class). In this case, the class child has two parts: a derived part and an incremental
part. The derived part is inherited from the class parent. The incremental part is the
new code written specifically for the class child.
Dynamic binding:
Binding refers to linking of procedure call to the code to be executed in response to
the call. Dynamic binding(or late binding) means the code associated with a given
procedure call in not known until the time of call at run time.
Message passing:
An object oriented program consists of set of object that communicate with each
other. Objects communicates with each other by sending and receiving information .
A message for an object is a request for execution of a procedure and there fore
invoke the function that is called for an object and generates result
Its Areas of application
 Client-Server Systems. ...
 Object-Oriented Databases.
 Object-Oriented Databases.
 Real-Time System Design.
 Simulation and Modeling System.
 Hypertext and Hypermedia

2. IMPERATIVE PROGRAMMING
Imperative programming is a paradigm of computer programming where the program
describes steps that change the state of the computer. Unlike declarative programming,
which describes "what" a program should accomplish, imperative programming explicitly
tells the computer "how" to accomplish it. Programs written this way often compile to
binary executables that run more efficiently since all CPU instructions are themselves
imperative statements.
Characteristics
a. The basic unit of abstraction is the PROCEDURE, whose basic structure is a
sequence of statements that are executed in succession, abstracting the way that
the program counter is incremented, so as to proceed through a series of machine
instructions residing in sequential hardware memory cells.
b. The sequential flow of execution can be modified by conditional and looping
statements (as well as by the very low-level goto statement found in many
imperative languages), which abstract the conditional and unconditional branch
instructions found in the underlying machine instruction set.
c. Variables play a key role, and serve as abstractions of hardware memory cells.
Typically, a given variable may assume many different values of the course of the
execution of a program, just as a hardware memory cell may contain many
different values. Thus, the assignment statement is a very important and
frequently used statement.

Imperative Programming can be Different Types of:

1. Machine and Assembly languages ie. Low level imperative language.

2. Procedural languages ie. High level imperative language.

3. Structural & modular languages

4. Object oriented languages


5. Event Driven programming languages

6. Object Based Languages

3. Structured Programming

It is a programming with a specific structure of the program and modular programming is added
with structured language to add different functions. These are high level imperative languages
with assignment statements, calculative statements, evaluation statements to execute complex
expressions which may have arithmetic, relational & logical operators and function evaluations,
and the assignment of the resulting value to memory.

Looping statements like while, do while, for loop, etc. used to execute sequence, conditional
branching, switch case statements and looping statements and subroutine or procedure call.
Imperative languages are like Fortran, BASIC, Pascal, COBOL, ALGOL language for
mathematical algorithms and C language,

4. procedural Programming

Procedural programming is the standard approach used in traditional computer language such as
C, Pascal, FORTRAN & BASIC. The basic idea is to have a program specify the sequence of
steps that implements a particular algorithm . Procedural programming is a term used to denote
the way in which a computer programmer writes a program.

This method of developing software, which also is called an application, revolves around
keeping code as concise as possible. It also focuses on a very specific end result to be achieved.
Procedural programming creates a step by step program that guides the application through a
sequence of instructions. Each instruction is executed in order.

5. Declarative Programming Languages

Most declarative programming languages stem from work in artificial intelligence and automated
theorem proving, areas where the need for a higher level of abstraction and a clear semantic
model of programs is obvious. The basic property of a declarative programming language is that
a program is a theory in some suitable logic. This property immediately gives a precise meaning
to programs written in the language. From a programmers point of the the basic property is that
programming is lifted to a higher level of abstraction. At this higher level of abstraction the
programmer can concentrate on stating what is to be computed, not necessarily how it is to be
computed.

The programmer gives the logic but not necessarily the control. Declarative programming can be
understood in in a weak and a strong sense. Declarative programming in the strong sense then
means that the programmer only has to supply the logic of an algorithm and that all control
information is supplied automatically by the system. Declarative programming in the weak sense
means that the programmer apart from the logic of a program also must give control information
to yield an efficient program

6. Functional programming

In functional programming languages programs are built from function definitions. To give
meaning to programs they are typically mapped on some version of the λ-calculus which is then
given a denotational semantics. There are both impure (strict) functional languages like Standard
ML allowing things like assignment and pure (lazy) functional languages like Haskell.

Modern functional languages like Haskell come rather close to achieving declarative
programming in the strong sense since programmers rarely need to be aware of control. On the
other hand the execution order of lazy evaluation is not very easy to understand and the real
computational content of a program is hidden under layers and layers of syntactic sugar and
program transformations. As a consequence the programmer loses control of what is really going
on and may need special tools like heap-profilers to find out why a program consumes memory
in an unexpected way.

To fix the behavior of programs the programmer may be forced to rewrite the declarative
description of the problem in some way better suited to the particular underlying implementation.
Thus, an important feature of declarative programming may be lost – the programmer does not
only have to be concerned with how a program is executed but has to understand a model that is
difficult to understand and very different from the intuitive understanding of the program.
7. Logic programming

For practical applications there exists one logic programming in use: Prolog. Prolog is used for a
wide variety of applications in artificial intelligence, knowledge based systems, and natural
language processing.

A (pure) Prolog program is understood as a set of horn clauses, a subset of first order predicate
logic, which can be given a model-theoretic semantics. Programs are evaluated by proving
queries with respect to the given program. From a programming point of view Prolog provides
two features not present in functional languages, built-in search and the ability to compute with
partial information. This is in contrast to functional languages where computations always are
directed, require all arguments to be known and give exactly one answer.

8. Event driven programming

These languages are imperative style with object based events handlers like Visual Basic &
PHP with Web designating [Link] with GUIs often use Event-Driven Programming
. Program waits for events to occur and then responds

Examples of events:

» Clicking a mouse button

» Dragging the mouse

» Pressing a key on the keyboard

Firing an event—when an object generates an event

Listener—object that waits for events to occur

Event handler—method that responds to an event

Common questions

Powered by AI

Imperative programming revolves around how the computer should achieve tasks, requiring the programmer to define step-by-step instructions that change the program's state. Declarative programming, in contrast, emphasizes what the outcome should be, leaving the control flow and execution order to the underlying system. In imperative programming, the programmer is deeply involved in controlling the execution flow, often optimizing for performance and efficiency, whereas, in declarative programming, the focus is more on defining the logic and leaving execution to the system. This difference represents a shift from control-oriented to problem-oriented programming .

Functional programming achieves high levels of abstraction by focusing on composing functions rather than managing state and control flow, as seen in imperative paradigms. Programs are built from pure functions that avoid side effects, enabling clearer attribution of output to input. The use of high-order functions, closures, and immutability allows for more concise representations of complex operations, often leading to more readable and maintainable code. Functional languages, by abstracting control details and state changes, permit developers to focus on the expressive power of mathematical function composition rather than procedural steps, thus streamlining problem-solving .

Encapsulation and data abstraction are closely related in object-oriented programming. Encapsulation wraps data and functions into a single unit, usually a class, and restricts access to certain components, promoting information hiding. Data abstraction, on the other hand, focuses on including only essential characteristics of an object without diving into the implementation details. An example of encapsulation is a class that has private data members accessed through public methods, while data abstraction might involve a class interface that provides a list of operations without exposing underlying complexities. Both these concepts help in reducing complexity and increase modularity by allowing developers to manage and understand the object-focused design .

Inheritance in object-oriented programming allows a new class, known as a derived class, to inherit attributes and behaviors from an existing class, known as the base class. This capability directly supports software reuse by enabling developers to extend existing software without modifying original code, thus promoting code reusability and system extensibility. Inheritance allows changes or enhancements to be made in derived classes while preserving and leveraging existing functionality, supporting the gradual and incremental development of complex systems with reduced errors and development time .

Polymorphism in object-oriented programming allows objects to be treated as instances of their parent class, enabling multiple forms or behaviors while using a single interface. This is significant for software extensibility as it allows developers to introduce new functionality with minimal modifications to existing code. Polymorphic behavior is achieved through mechanisms like function overloading and operator overloading, facilitating a flexible system design where adding new functionalities or objects is manageable and efficient, supporting an evolutionary software development process .

Message passing in object-oriented programming consists of objects interacting with each other by sending and receiving messages. This approach is crucial in systems design, as it encapsulates interaction logic, allowing objects to communicate without needing to know each other's internal workings. It fosters modularity and flexibility since systems can be easily scaled and modified by adding new objects or altering object interactions without affecting overall system integrity. Message passing is particularly valuable in designing distributed systems, client-server models, and real-time applications where communication efficiency and decoupling are critical .

Logic programming, exemplified by languages like Prolog, provides strong tools for artificial intelligence and knowledge-based systems due to its declarative nature, allowing complex problems to be solved as logical queries. By representing knowledge in rule-based formats and utilizing built-in search capabilities, logic programming efficiently handles partial information and uncertainties often encountered in AI problems. However, its reliance on backtracking and resolution can lead to abstract and sometimes non-intuitive processes, requiring sophisticated understanding for optimization. Despite these challenges, logic programming remains pivotal in domains requiring symbolic reasoning and automated theorem proving .

Event-driven programming is highly beneficial for developing GUI applications as it inherently adapts to the asynchronous nature of user interactions, such as mouse clicks or key presses. By allowing programs to respond to user actions with events and handlers, developers can create dynamic and interactive interfaces that improve user experience. The decoupled architecture of event-driven environments enables easier updates and maintenance since changes can often be made in isolated event handler functions without requiring a comprehensive rewrite of the entire application logic, thus enhancing versatility in GUI design .

Procedural programming is instrumental in the traditional implementation of algorithms and automation processes. By essentially providing a step-by-step guide to executing tasks, procedural programming ensures that algorithms can be precisely represented and systematically carried out via sequences of executable instructions. This paradigm is particularly suited for tasks where the algorithm's flow and logic must be transparently and predictably managed, such as in scripting and automation activities, where clear and efficient sequences of operations are necessary .

Lazy evaluation in functional programming, such as in Haskell, delays the computation of expressions until their values are needed, which can greatly improve performance by avoiding unnecessary calculations, potentially leading to more efficient memory usage. However, this approach introduces challenges in understanding execution order, often obscured by layers of syntax and transformations, making debugging difficult. Moreover, programmers might lose control over resource usage, requiring tools like heap profilers to diagnose memory issues unexpectedly. Despite these challenges, lazy evaluation enables developers to construct highly modular programs with highly reusable functions, facilitating a high level of abstraction .

You might also like