What is OOPS?
OOPS treats data as critical factor, and doesn’t allow the data to move around the system. It means OOPS tries to protect data. OOPS divides the problem into objects. Objects contains data and functions together. The whole responsibility is divided into objects or we can say that objects interacts with each other without affecting the data stored in them. Only functions of objects can access the function of another objects.
Structure of OOPS:
Characteristics of Object Oriented Programming are:
- It gives importance to data rather than procedure or functions.
- Programs are divided into Objects rather than functions.
- Data is protected and can`t accessed easily.
- Objects only interact with each other to accomplish a tasks.
- Solves the problem of real world.
- It based on Bottom-Up approach.
Difference between OOPS and POP:
- It uses top-down approach. It uses Bottom-Up approach.
- It solves real world problem. Can`t solve the real world problem.
- The program is divided into Objects. The program is divided into Functions.
- Gives security of data stored in Objects. No security. Global data can be accessed easily.
Basic concept of OOP: It includes:-
- Data Abstraction and Encapsulation
- Data Binding
- Message Passing
A. Objects: Object is an essential element of OOPS paradigm. Object is an Entity, an entity can be defined thing having some attributes or characteristics and existed in real world. Entity can be Person, Student, Fanetc.
Objects are run time entity and stores or bound the data or functions together in it. Data or variable stored in object represents the features or characteristics of an Objects and functions defines what action is to be done on the objects.
Eg:- Person is an Object.
Variables or data are:
Name of Person
Id of a Person
Date of Birth, Address of a person
Variables are: Size, Color, product_id.
Functions are: Measure, Draw lines
Objects always takes a memory space. Objects are totally dependent on class or template.
Eg: Student std;
B. Classes: A class is a Blueprint, which doesn't exists or can`t work independently. The entire data or function stored in objects are defined accordingly the class. Classes are collection of variables and functions. Variables of classes are known as member functions. Classes are used to declare objects of that class. More than one object of a class can be created.
For Eg: Fruit is a class and Mango, banana, apples oranges are objects of fruit class.
Definition of class is always enclosed or end with the semicolon. [;]
C. Data Abstraction and Encapsulation: the term Abstraction refers to act of representing an essential features without knowing the background details. The real world example is Switchboard. Switchboard totally contains buttons. In which we press button according to our requirements, what is happening inside, how the buttons are working we need not to know about it.Classes uses Data Abstraction and a classes which uses Data Abstraction is known as Abstract data type because classes are also a data type which is user defined.
Encapsulation: the act of binding both data and functions into a single unit or single class is known as Encapsulation. Encapsulation defines the security of the variable or data stored in class. It doesn’t allow the data to move around and not make them accessible to the outside world.
D. Inheritance: this feature provides the reusability. The term inheritance defines the hierarchical structure. Inheritance is process of creating a new class by using the data member or member functions of existing class.
Two mainly terms are used in inheritance:
- Parent class/Super class: the existing class, which giving its feature is known as parent class or super class.
- Child class/Sub class: a class which taking the features of existing class is known as subclass.
E. Polymorphism: It is a Greek word which means multiple forms, or we can say that single name having a multiple images. The polymorphism allows programmer to make a function in a class and provides a facility to make same function with same name in another class with different functionality. The main thing is to be remember is the signature or parameters used in both functions. Parameters must be different.
And difference can be in:-
a. Number of parameter to be passed.
b. The sequence of parameter.
c. Data types of the parameters passed.
F. Dynamic Binding: it refers to create a link of a procedure call to code executed every procedure needs a link to create between its code or definition and function or procedure name.
G. Message Passing: when a program is executed the object communicates with each other by sending a message to each other. Message contains the information to send or receive.
The message passing process contains:
- Name of object.
- Name of message.
- Information that is to be passed.
Benefits of OOP: -
- It takes care of data and ensure the security of data stored in object.
- Provides reusability through inheritance.
- Redundant code can be removed.
- Objects provides easy and flexibility in work.
- Member functions can be easily removed or inserted.
- Complexity of software can be easily managed.
Applications of OOPS:-
- CAD/CAM system.
- Real time system.
- AI system
- Expert system.
- OOPS based database.