Object Oriented Programming
Programming Paradigm : A Programming Paradigm defines the methodology of designing and implementing programs using the key features and building blocks (such as keywords, functions, structure, etc) of a programming language.
Various Programming Paradigm –
1-
Procedural Programming
2-
Object Based Programming
3-
Object Oriented Programming
Procedural Programming :
Procedural programming paradigm separates the functions and the data manipulated by them.In Procedural Programming language, whenever the
definition of a type is changes, the function referred to this must also be
changed.
Suppose , we are using structure and a separate functions
for entering and displaying the content or data of the structure.
Now , if after some time, we feel the need of adding a
new element in the structure (i.e. extending the program ), then all the
functions working on that structure must also be modified to cope with the
change in structure.
This leads to increased time and cost overheads during
design changes or maintaining the software.
Object Based Programming :
In object based programming, data and its associated
meaning functions are enclosed in one single entity i.e. a class.
Whenever there is a change in the definition of type,
user’s interface remains unaffected genetally.
Some features of Object based programming are information hiding,
abstraction, classes, function overloading, etc.
The advantages of Object based programming is it overcomes
most shortcomings of procedural programming, support user-defined types,
implements information hiding and abstraction, etc.
Object Oriented Programming :
The object oriented programming paradigm is superset of
object based programming. It offers all the features of object based
programming and overcomes the limitation.
Object oriented programming approach reduce the complexity of the program
and make software reuse feasible and possible.
The general concepts of OOPs are Data Abstraction, Data
Encapsulation, Modularity, Inheritance, Polymorphism.
Data Abstraction : It refers to the act of representing essential
features without including the background details or explanations.
Ex- When we drive a car, we only knows the essential
features to drive a car (i.e. use gear to change speed , use steairtnn wheel to
change the direction, etc ) but we does not know actually how the gears
changes, how engine works, and the mechanism of car.
Encapsulation : The wrapping up of whole
data and operations/functions into a single unit (called class ) is known as Encapsulation.
Modularity : Modularity us the property of
a system that has been decomposed into a set of cohesive and loosely coupled
modules.
Ex- We use a complete music system but actually the music
system comprises of speakers, cassette-player, record-player, cd-player, tuner,
mic, etc. which is a good example of Modularity.
Inheritance : Inheritance is the capability
of one class of things to derive capabilities or properties from another class.
Ex- We are humans. We inherit from the class ‘Human’ having
certain properties, such as ability to speak, breathe, eat, drink etc. But
these properties are not unique to humans. The class ‘Human’ inherits these
properties from the class ‘Mammal’ which again inherits some of its properties
from another class ‘Animal’.
Polymorphism : Polymorphism is the ability
for a message or data to be processed in more than one form.
Polymorphism is a property by which the same message can
be sent to objects of several different classes, and each object can respond in
a different way depending on its class.
Ex- Both Parrot and Owl are derived from same class (or
group) i.e. birds but both parrot and owl have different capabilities like owl
can see clearly in night but parrot cannot, and parrot can copy anyone’s voice
but owl cannot.
Class and Object
Class : A class is a group of elements that share common properties and
relationships.
Object : An object is an identifiable entry with some
characteristics and behavior .
Syntax:
class class_name {
private :
element1 ;
function1 ;
protected :
element2 ;
function2 ;
public :
element3 ;
function3 ;
} ;
class_name object1, object2 ;
0 comments:
Post a Comment
Please give your valuable suggestions