Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Computer Programming One

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

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 behavior.OOP focuses on the objects
that developers want to manipulate rather than the logic required to manipulate
them.OOP 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 languages.Programs 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

You might also like