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

Object-Oriented Programming (OOP)

 OOP treats data as a critical element in the program


development and does not allow it to flow freely around the
system.
 In OOP, the major emphasis is on data rather than procedure
(function).
 It ties data more closely to the function that operate on it, and
protects it from accidental modification from outside function.
 OOP allows decomposition of a problem into a number of
entities called objects and then builds data and function around
these objects.
 The data of an object can be accessed only by the function
associated with that object. However, function of one object
can access the function of other objects.
 C++, Java, Dot Net, Python etc are the example of Object
oriented programming (OOP) language.

Some Characteristics of Object Oriented Programming:-

 Emphasis is on data rather than procedure (function).


 Programs are divided into objects.
 Functions that operate on the data of an object are ties
together in the data structure.
 Data is hidden and cannot be accessed by external function.
 Objects may communicate with each other through function.
 New data and functions can be easily added whenever
necessary.
 Follows bottom up approach in program design.

Features of OOP (Object Oriented Programming):-

1. Class
2. Object
3. Encapsulation
4. Data Abstraction
5. Inheritance
6. Polymorphism
7. Data binding
8. Message Passing
Features of OOP
OOP stands for Object Oriented Programming and the language that
support this Object Oriented programming features is called Object
oriented Programming Language. An example of a language that
support this Object oriented features is C++.

Features of Object oriented Programming

The Objects Oriented programming language supports all the features of


normal programming languages. In addition it supports some important
concepts and terminology which has made it popular among
programming methodology.

The important features of Object Oriented programming are:

 Inheritance
 Polymorphism
 Data Hiding
 Encapsulation
 Overloading
 Reusability
Let us see a brief overview of these important features of Object
Oriented programming

But before that it is important to know some new terminologies used in


Object Oriented programming namely

 Objects
 Classes
Objects:

In other words object is an instance of a class.

Classes:

These contain data and functions bundled together under a unit. In other
words class is a collection of similar objects. When we define a class it
just creates template or Skelton. So no memory is created when class is
created. Memory is occupied only by object.

Example:

Class classname
{
Data
Functions
};
main ( )
{
classname objectname1,objectname2,..;
}

In other words classes acts as data types for objects.

Member functions:

The functions defined inside the class as above are called member
functions.
Here the concept of Data Hiding figures

Data Hiding:

This concept is the main heart of an Object oriented programming. 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. Object
Oriented programming gives importance to protecting data which in any
system. This is done by declaring data as private and making it
accessible only to the class in which it is defined. This concept is called
data hiding. But one can keep member functions as public.

So above class structure becomes

Example:

Class classname
{
private:
datatype data;

public:
Member functions
};
main ( )
{
classname objectname1,objectname2,..;
}
Encapsulation:

The technical term for combining data and functions together as a


bundle is encapsulation.

Inheritance:

Inheritance as the name suggests is the concept of inheriting or deriving


properties of an exiting class to get new class or classes. In other words
we may have common features or characteristics that may be needed by
number of classes. So those features can be placed in a common tree
class called base class and the other classes which have these
charaterisics can take the tree class and define only the new things that
they have on their own in their classes. These classes are called derived
class. The main advantage of using this concept of inheritance in Object
oriented programming is it helps in reducing the code size since the
common characteristic is placed separately called as base class and it is
just referred in the derived class. This provide the users the important
usage of terminology called as reusability

Reusability:

This usage is achieved by the above explained terminology called as


inheritance. Reusability is nothing but re- usage of structure without
changing the existing one but adding new features or characteristics to
it. It is very much needed for any programmers in different situations.
Reusability gives the following advantages to users

It helps in reducing the code size since classes can be just derived from
existing one and one need to add only the new features and it helps
users to save their time.

For instance if there is a class defined to draw different graphical figures


say there is a user who want to draw graphical figure and also add the
features of adding color to the graphical figure. In this scenario instead of
defining a class to draw a graphical figure and coloring it what the user
can do is make use of the existing class for drawing graphical figure by
deriving the class and add new feature to the derived class namely add
the feature of adding colors to the graphical figure.

Polymorphism and Overloading:

Poly refers many. So Polymorphism as the name suggests is a certain


item appearing in different forms or ways. That is making a function or
operator to act in different forms depending on the place they are
present is called Polymorphism. Overloading is a kind of polymorphism.
In other words say for instance we know that +, – operate on integer
data type and is used to perform arithmetic additions and subtractions.
But operator overloading is one in which we define new operations to
these operators and make them operate on different data types in other
words overloading the existing functionality with new one. This is a very
important feature of object oriented programming methodology which
extended the handling of data type and operations.

Thus the above given important features of object oriented programming


among the numerous features it have gives the following advantages to
the programming world. The advantages are namely

• Data Protection or security of data is achieved by concept of data


hiding

• Reduces program size and saves time by the concept of reusability


which is achieved by the terminology of Inheritance

• Operators can be given new functions as per user which extends the
usage.

Application of Object Oriented Programming:-

 User interface design such as windows, menu


 Real Time Systems such as Control system for cars, aircraft,
space vehicles etc
 Office automation system such as Document Management
System i.e. Word processing system, spread sheet software
etc
 AI and Expert System
 Neural Networks and parallel programming System
 Decision support system etc

Advantages of OOP:-

1. Improved software-development productivity:


Object-oriented programming is modular, as it provides separation of
duties in object-based program development. It is also extensible, as
objects can be extended to include new attributes and behaviors.
Objects can also be reused within an across applications. Because of
these three factors – modularity, extensibility, and reusability – object-
oriented programming provides improved software-development
productivity over traditional procedure-based programming techniques.

2. Improved software maintainability:


Since the design is modular, part of the system can be updated in case
of issues without a need to make large-scale changes.
3. Faster development:
Reuse enables faster development. Object-oriented programming
languages come with rich libraries of objects, and code developed
during projects is also reusable in future projects.
4. Lower cost of development:
The reuse of software also lowers the cost of development. Typically,
more effort is put into the object-oriented analysis and design, which
lowers the overall cost of development.

5. Higher-quality software:
Faster development of software and lower cost of development allows
more time and resources to be used in the verification of the software.
Although quality is dependent upon the experience of the teams, object
oriented programming tends to result in higher-quality software.

Disadvantages of OOP:-

1. Larger program Size:


Object oriented programs are much larger than other programs. In the
early days of computing, space on hard drives, floppy drives and in
memory was at a premium. Today we do not have these restrictions.
2. Effort:
Object oriented programs require a lot of work to create. Specifically, a
great deal of planning goes into an object oriented program well before
a single piece of code is ever written. Initially, this early effort was felt
by many to be a waste of time. In addition, because the programs were
larger, coders spent more time actually writing the program.
3. Speed:
Object oriented programs are slower than other programs, partially
because of their size. Other aspects of Object Oriented Programs also
demand more system resources, thus slowing the program down.

Procedural Oriented Programming (POP)


 In the procedure oriented approach, large programs are
divided into smaller programs known as functions.
 In POP, a program is written as a sequence of procedures or
function.
 In POP, each procedure (function) contains a series of
instructions for performing a specific task.
 During the program execution each procedure (function) can
be called by the other procedures.
 To call a procedure (function), we have to write function name
only.
 While we concentrate onto the development of functions, we
give very little attention to the data that are being used by
various functions.
 In POP, the major emphasis is on procedure (function) and not
on the data.
 In a multi-function program, many important data items are
placed as global so that they may be accessed by all the
functions. Each function may have its own local data.
 Global data are more vulnerable to an accidental change by a
function. In a large program it is very difficult to identify what
data is used by which function.
 Examples of procedural oriented programming language are
COBOL, FORTRAN, PASCAL, C programming language etc.

Characteristics of procedure-oriented programming:-

 Large programs are divided into smaller programs known as


functions.
 Most of the functions share global data.
 Data move openly around the system from function to function.
 Functions change the value of data at any time from any place.
(Functions transform data from one form to another.)
 It uses top-down approach in program design.

Drawback:-
 In POP, global data can be accessed & changed by any
procedure (function) so there is no data security. In case if we
want to change type of data of global data, then we also need
to resolve all functions that access the data. Due to this it may
happened that some errors will occurs
 POP does not model real world problems because functions
are action oriented.

Difference between OOP and POP:


OOP POP

Object oriented. Structure oriented.

Program is divided into objects. Program is divided into functions.

Bottom-up approach. Top-down approach.

Inheritance property is used. Inheritance is not allowed.

It uses access specifier. It doesn’t use access specifier.

Encapsulation is used to hide the


data. No data hiding.

Concept of virtual function. No virtual function.

Object functions are linked Parts of program are linked


through message passing. through parameter passing.

Adding new data and functions is Expanding new data and


easy functions is not easy.

The existing code can be reused. No code reusability.

Not suitable for solving big


use for solving big problems. problems.

C++, Java. C, Pascal.

You might also like