Thursday, April 16, 2015

Object Oriented Programming Concepts Part-1

Object Oriented Programming Concepts part 1



We are programmers and now the world is only using Object Oriented Programming (OOP)s concepts.

Many of us don't have clear concepts about all the fundamentals of OOPs, and if base is not cleared then we cant do well programming.
So this tutorial will provide you a very short and descriptive meanings of Terms in OOP.

Main word in OOP is Object. So what is this Object?
Let us take Universe example so in this, we can treat Planets like earth, Mars, Neptune etc as an Object.
Further going inside the Object earth it has many things like human, trees, vehicles etc.
In the same way we can imagine a Car made up of different objects like steering, wheel, body etc.

In the same way we have object oriented programming which assumes everything as an object and used in a software using different objects.
Object Oriented Concepts:

Let us define important terms of Object Oriented Programming.




Class: Programmer defines a data type, in which he writes local functions as well as local data is called Class. A class is same as a template through which many instances can be made as object.

Object: This is an individual instance of the data structure defined by a class. You can define a class once and then make many objects that belong to it.

Member Variable: Variables which are inside a class are known as member variables. This will be invisible outside of the class. Once an object is created then these variables will become attribute of the object.

Member function: Functions which defined inside a class and are used to access object data are called member function.

Inheritance: When a class is defined by using existing function of a parent class then it is called inheritance. In this child class will inherit all or few member functions and variables of a parent class. Types of inheritance Single, Multiple and Multilevel.

Polymorphism:  The ability to appear in many forms i.e in this if function is used for different purposes then it is called Polymorphism. Eg. if a function is used by passing different number of arguments for different purpose.

Overloading: It is a type of polymorphism in which some or all of operators have different implementations depending on the types of their arguments. Operator overloading and function overloading.

Data Abstraction:  It is the ability to provide only essential information to the outside world and hide their background details means to represent the needed information in program without presenting the details.

For its understanding Let's take one real life example of a TV, which you can turn on and off, change the channel, adjust the volume, and add external components such as speakers, VCRs, and DVD players, BUT you do not know its internal details, that is, you do not know how it receives signals over the air or through a cable, how it translates them, and finally displays them on the screen. 
Thus, we can say a television clearly separates its internal implementation from its external interface and you can play with its interfaces like the power button, channel changer, and volume control without having zero knowledge of its internals.

Example Taken from click here

Encapsulation: It is a concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse. 

Data encapsulation is a mechanism of bundling the data, and the functions that use them and data abstraction is a mechanism of exposing only the interfaces and hiding the implementation details from the user.

Constructor: It is a special type of function which will be called automatically whenever there is an object formation from a class.

Destructors: it is also a special type of function which will be called automatically whenever an object is deleted or goes out of scope.

Hope this will help in your understanding. Further if you have any doubts please feel free to contact or do comments.

In the next we will see examples on these all...

No comments:

Post a Comment