The Object Oriented programming is an approach that provides a way of modularizing programs for creating partitioned memory area for both data and methods that can be used as templates for creating copies of such modules on demand.
The OOP treats data as a critical element in the program
development and does not allow it flow freely around the system. It combined
data and methods very closely to work together. And give protection from other
members.
The OOP allows us decompose a problem into a number of
entities called as Objects. The combination of data and methods make up an
Object. The private-data of an object can be accessed by only methods in that
object. The public-methods of an object can be accessed by the methods of
another object.
The programs in OOPS, classified into classes & Objects.
The classes & objects enable Data hiding through Encapsulation &
Data-abstraction, Reusability through Inheritance. Polymorphism enables methods
and operators to perform different activities in different situations.
Ø Basic Concepts of Object Oriented Programming
Some of the concepts used extensively in object-oriented
programming are:
• Objects
• Classes
• Data abstraction and encapsulation
• Inheritance
• Polymorphism
• Dynamic binding
• Message passing
Objects
Objects are the basic run time entities in an object-oriented
system. They may represent a person, a place, a bank account, a table of data
or any item that the program has to handle.
Programming problem is analyzed in term of objects and the
nature of communication between them.
Objects take up space in the memory and have an associated
address. When a program is executed, the objects interact by sending messages
to one another.
Each object contain data, and code to manipulate data.
Objects can interact without having to know details of each other’s data or
code.
Class
The entire set of data and code of an object can be made a
user-defined data type with the help of class. Objects are variables of the
type class.
Once a class has been defined, we can create any number of
objects belonging to that class. Each object is associated with the data of
type class with which they are created. A class is thus a collection of objects
similar types.
The syntax used to create an object is not different then the
syntax used to create an integer object in C.
Example: If student is a class and s1 is the object
student s1;
will create object s1 belonging to class student.
Data Abstraction and Encapsulation
The wrapping up of data and function into a single unit
(called class) is known as encapsulation.
The data is not accessible to the outside world, and only
those functions which are wrapped in the class can access it. These functions
provide the interface between the object’s data and the program. This
insulation of the data from direct access by the program is called data
hiding or information hiding.
Abstraction refers to the act of representing essential
features without including the background details or explanation. Classes use the concept of abstraction.
Inheritance
Inheritance is the
process by which objects of one class acquired the properties of objects of
another classes.
In OOP, the concept of inheritance provides the idea of reusability.
This means that we can add additional features to an existing class without
modifying it. This is possible by deriving a new class from the existing one.
The new class will have the combined feature of both the classes.
Polymorphism
Polymorphism, a Greek term, means the ability to take more
than on form. Polymorphism is another important OOP concept.
An operation may exhibit different behavior in different
instances. The behavior depends upon the types of data used in the operation. The
process of making an operator to exhibit different behaviors in different
instances is known as operator overloading.
Using a single function name to perform different type of
task is known as function overloading.
Polymorphism plays an important role in allowing objects
having different internal structures to share the same external interface. Polymorphism
is extensively used in implementing inheritance.
Dynamic Binding
Binding refers to the linking of a procedure call to the code
to be executed in response to the call. Dynamic binding means that the code
associated with a given procedure call is not known until the time of the call
at run time. It is associated with polymorphism and inheritance.
Message Passing
An object-oriented program consists of a set of objects that
communicate with each other. Objects communicate with one another by sending
and receiving messages.
A Message for an object is a request for execution of a
procedure, and therefore will invoke a function (procedure) in the receiving
object that generates the desired results.
Message passing involves
specifying the name of object, the name of the function (message) and the
information to be sent.
Example:
Employee.salary(name);
Here Employee is a class, salary is a method and name is the
information.
Ø Benefits of OOP
OOP offers several benefits to both the program designer and
the user. This technology promises greater programmer productivity, better
quality of software and lesser maintenance cost. The principal advantages are:
-
Through inheritance, we can eliminate redundant
code extend the use of existing Classes.
We can build programs from the standard working modules that communicate with one another, rather than having to start writing the code from scratch. This leads to saving of development time and higher productivity.
- The principle of data hiding helps the programmer to build secure program that can not be invaded by code in other parts of a programs.
- The data-centered design approach enables us to capture more detail of a model can implemental form.
- Object-oriented system can be easily upgraded from small to large system.
-
Message passing
techniques for communication between objects makes to interface descriptions
with external systems much simpler.
-
Software
complexity can be easily managed.
Ø Application of OOP
The promising areas of application of OOP include:
• Real-time system
• Simulation and modeling
• Object-oriented databases
• Hypertext, Hypermedia
• AI and expert systems
• Neural networks and parallel
programming
• Decision support and office
automation systems
• CAM/CAD systems
0 comments:
Post a Comment