Programming Paradigms
Programming Paradigms
Programming paradigms
• Paradigm-method to solve some problem or
do some task.
• Programming paradigm-an approach to solve
problem using some programming language.
Contd...
Contd..
• Imperitive - the programmer instructs the
machine how to change its state (how to do).
• Declarative- do not state the order in which to
execute operations. Instead, they supply a
number of operations that are available in the
system, along with the conditions under which
each is allowed to execute (what to do).
Contd...
• Procedural - Groups instructions into
procedures.
• Object oriented - Groups instructions together
with the part of the state they operate on.
• Parallel processing approach- A parallel
processing system posses many numbers of
processor with the objective of running a
program in less time by dividing them. C/C++
also supports because of some library function.
Contd...
• Logic programming- Here we have a knowledge base which we
know before and along with the question and knowledge base
which is given to machine, it produces result. machine learning
we have some models like Perception model which is using the
same mechanism.
• Functional- The functional programming paradigms has its roots
in mathematics and it is language independent.
• Database - This programming methodology is based on data and
its movement. Program statements are defined by data rather
than hard-coding a series of steps. A database program is the
heart of a business information system and provides file creation,
data entry, update, query and reporting functions.
C and C++
• C-Procedural language
• C++ - Procedural and object oriented language
Procedural oriented programming
• System is defined as set of procedures that
interact with data.
• Data is maintained separately from procedures.
• List of instructions for a computer to follow.
• Group of similar tasks are organised as
functions.
• Most functions share global data.
• Data is publicly available.
Object oriented programming
• System is defined as a collection of objects that work
together to accomplish task.
• Each object maintains its own data.
• Emphasis on data rather than the procedure.
• Programs are divided into objects .
• Data structures are designed such that they characterize
the object.
• Functions that operate on the data of an object are tied
together in that same data structure.
• Data is hidden and cannot be directly accessed.
Contd...
Contd...
Contd...
Class and object structures
• There are class structure and object structure
at a higher level of abstraction
• These makes up complex systems, for
example, a jet engine, an airframe, the
various types of seats, an autopilot subsystem
and so forth
Class structure- Abstraction
Object structure-Decomposition
Features
• Encapsulation
• Abstraction
• Inheritance
• Polymorphism
Encapsulation
• Binding or wrapping up the attributes and the
related functionalities of a class into a single
unit.
Contd..
Access specifiers
Abstraction
• Knowledge of what the functionality is about
(i.e.) how to use it but not how the
implementation is done.
Contd...
Contd..
Contd...
Contd...
• Show room class will not have any knowledge
of code that is written in the function
switch_operate() of class Fan.
• Actually the knowledge is not needed.
• It is abstraction.
Why abstraction?
Application of OOP
• Real-business system are often much more
complex and contain many more objects with
complicated attributes and method.
• Real-time system
• Simulation and modeling
• Object-oriented data bases
• AI and expert systems
• Neural networks and parallel programming
OOP languages