Вы находитесь на странице: 1из 9

1.

1 PROCEDURE ORIENTED PROGRAMMING


Procedure Oriented Programming (POPs) is the oldest methodology of
program development that mainly focus on problem not on data. To
solve the particular problem, it implies modular approach in which large
program is divided into small parts called functions or procedures that
operate on data.

In POPs, data and functions are treated as separate entities. Data can
move from one function to another function freely.

Main Program

Function- Function- Function-3


1 2

Function- Function- Function- Function- Function-


1.1 1.2 2.1 3.1 3.2

Procedural Language
Paradigm
1.2 OPP PARADIGM
Today, there are many popular programming languages (such as Java,
JavaScript, C#, C++, PHP, Ruby, Small Talk etc. ) that support object-
oriented programming (OOP) concepts.

In OOPs, programming may be seen as the design of software consisting


of cooperating objects, whereas in POP (Procedure Oriented
Programming), programming may be seen as the design of software
consisting of functions.

In OOP, each object is capable of processing data, sending and receiving


messages to or from other objects. Each object can be treated as an
independent unit having its own distinct role. Object-oriented
programming is used to promote greater flexibility and maintainability
in program and is widely popular in large-scale software engineering
projects.

In OOPs, programmers can define data type of data structure, operations


(that can be applied to the data structure) and relationship among the
data structures. Thus, the data structure becomes an object that includes
both data and operations.

Data Members Data Members

Member Functions Member Functions

Data Members

Member Functions

OOP Paradigm
ADVANTAGES OF OOP
 One of the principal advantages of object-oriented programming
techniques over procedural programming technique is that it enables
programmers to create modules that do not need to be changed when
a new type of object is added.

 A programmer can simply create a new object that inherits many of


its features from existing objects. It makes object-oriented programs
easier to modify.

 The object oriented programming techniques provide better


productivity and quality of software.

 Through Inheritance, we can eliminate redundant code.

 Data hiding feature helps in building secure programs.

 It’s possible to have multiple instances of an object.

 Software complexity can be easily managed.

 Message passing techniques for communication between the objects


are simple.

 OOP makes it easy to maintain and modify existing code as new


objects can be created with small differences to existing ones.

 OOP provides a good framework for code libraries. This is


particularly useful for developing graphical user interfaces.
DISADVANTAGES OF OOP
 In OOPs code becomes lengthier when a programmer uses
Template, Multiple Inheritance, Exceptional handling, Virtual base
classes and classes for IO Streams.

 Decreased system / software performance: With many OOPLs (such


as Java) being interpreted, rather than compiled into native machine
code, run- time speeds are impaired.

 OOPs has problem with dynamic memory allocation (the method


used to create objects), means that either more memory is used as
garbage, or that the system run-time speed is compromised by the
need for garbage collection.

CHARACTERISTICS OF OOP
Abstraction: A data abstraction lets you ignore the way the data is
represented in memory, and think in terms of what operations can be
performed on the data. Abstraction refers to the process of representing
essential features without including the background details. In OOPs, the
concept of abstraction is implemented via classes. Abstraction is
simplifying complex reality by modeling classes appropriate to the
problem, and working at the most appropriate level of inheritance for a
given aspect of the problem. Abstraction is also achieved through
Composition. For example, a class CAR would be made up of an Engine,
Gearbox, Steering objects, and many more components. To build the class
CAR, rather giving stress to know how the different components work
internally, one should only understand how to interact with them, i.e.,
send messages to them, receive messages from them, and perhaps make
the different objects composing the class interact with each other.
Encapsulation: Encapsulation is the process of combining data and
functions into a single unit called class. The method of encapsulation
provides the facility of data hiding. Therefore, Data is only accessible
through the functions present inside the class. Encapsulation leads to the
concept of data hiding, but the concept of encapsulation must not be
restricted to information hiding only. Encapsulation clearly represents the
ability to bundle related data and functionality within a single entity
called a class.
Example:

class c1
{
public:

int sample();
int example(char *se)
int endfunc();
.........
......... //Other member functions

private:

int x;

float sq;

......... //Other data members

};

In the above example, the data members integer x, float sq and other data
members and member functions sample (), example (char* se),
endfunc() and other member functions are bundled and put inside a single
entity called class c1. Here, data x and sq can only be accessed via
functions present inside the class c1. This exemplifies the concept of
Encapsulation.

Data Hiding: Data hiding is the implementation details of a class that


are hidden from the user. The data is hidden inside the class by declaring
it as private inside the class. When data or functions are defined as private
it can be accessed only by the class in which it is defined. When data or
functions are defined as public then it can be accessed anywhere outside
the class. The data security in Oops can be achieved by declaring data as
private and making it accessible only to the class in which it is defined. In
the above given example the data member x and sq are declared as private
and no one (except member function of the same class, here c1) can
access them from outside the class.

Inheritance: Inheritance is the process by which new classes called


derived classes are created from existing classes called base classes. The
derived class and base class are also called sub-class and super class
respectively. The derived class consist all the features of the base class as
well as its own features. Inheritance also provides the concept of code
reusability. The programmer can create as many as derived classes from
the base class by adding specific features to each derived class.

Father

Son-1 Son-2

Grands Grands Grands Grands


on on on on

Inheritance
Diagram
Syntax to implement Inheritance is :

class derived_classname : access_specifier baseclassname

Example

If the base class is c1 and the derived class is c2 it is specified as:

class c2 : public c1

Here class and public are keywords and c2, c1 are derived class and
base class name respectively.
Polymorphism: Polymorphism is a powerful feature of the object
oriented language. Here, “poly” means “many” and “morphism” means
“shapes or uses”. Therefore polymorphism means many uses or many
shapes. When an operator exhibits different-2 operations at the different-2
instances of time, it uses the concept of polymorphism. Like an operator
+, when operate on integer or float data perform mathematical operations
but when operate on characters/strings it concatenates them.

Examples:

• The below + operator refers to integer addition

6 + 10;

• The same + operator can be used with different meanings with


strings:

“Hello" + “Students“;

• The same + operator can also be used for floating point addition:

7.15 + 3.78;

Code Extensibility and Resuability: C++ allows the extension of the


functionality of the existing codes. In C++ this is achieved through
abstract classes and inheritance. The term reusability refers to the ability
for multiple programmers to use the same written and debugged existing
class of data.

User defined data type: C++ allows the definition of our own types
based on other existing data types. We can create user defined data type
by using the concept of typedef, union, structure, enumeration, classes
etc.

Вам также может понравиться