previously, we have discussed about why we should learn .net technology. In this section we will discuss about what is overview of object oriented programming.
An object oriented programming is a language which satisfy the condition of :
1.Abstraction
2.Encapsulation
3.Inheritance
4.Polymorphism
All these are the key concept of any object oriented programming language.
Let's see what exactly all these terms are?
1.Abstraction:
Abstraction is nothing but , it is a process to identify the key aspects of an entity and ignoring the rest.
In simple term, I will say then it is a process which only take the important aspect which is required for current senario.
For example,let's take a senario where a person visit to your house for social survey ,few qurstion he ask's while doing his survey i.e
1.name of all the person living in the house?
2.Occupation
3.Martial status
4.Qualification
5.age
6.religion
7.income etc.
Where as if we go to the hospital,the information which they ask or note is:
1.Name of a person
2.Age
3.Blood group
4.weight
5.previous medical report
so,we can see the difference for bothe senario where one requires different information than other or one requires more information than other.
So, here this information which is gathered by both this institution is nothing but the aspects which is important for both of them according to their institution , else their output will not meet with the expectation.
So,here the arise is , what is the differnce between object-based and object-oriented language?
The answer is,all languages that support abstraction , encapsulation , inheritance and polymorphism are known as object oriented language.
E.g:-
Java,c#,vb.net etc..
And on the other hand , All the languages that support abstraction and encapsulation ,but do not support inheritance and polymorphism are known as object based language.
E.g :- vb
2. Encapsulation:
Encapsulation in a simple term means 'data hiding', with the help of encapsulation one can hide data, internal structure and implementation details of an object.
Let's take an example of television , when we switch on the television what we see is visuals on the screen and we can change the channels with the help of remote control but,the functionality inside the television is hidden from end user.
In a similar way, in encapsulation an interface is provided to the end user to use it but the implementation of that interface is hidden from end user.
As we have talked about 'object' let us see what is meant by 'object'in .net.
Object:-
An object is an entity which has well defined structure and behaviour , it also possesses certain characteristic i.e,every object has state,behaviour , identity and responsibility.
For example :- a car is an object,an employee is an object.
An object can be tangible , intangible or concenptual.
Some more examples are air,sound,bank account etc.
What is meant by state of an object?
The state of an object includes the current values of all its attributes .
To give you guys a clear picture let's take an example of a window on a computer so, here your window acts as an object and the height , width, the background color and it's x-y co-ordinates is nothing but the attributes of window and the current values in those attributes will describe the state of that window say for example:
minimized will have different value,maximized will have different value,restore will have different value.
Behaviour of an object:-
Behaviour of an object is nothing but how an object reacts with the change in value.
For example:-
when we switch 'on' fan , we pass a value through which fan starts rotating and when we switch 'off' fan ,it slowly stops running,it means fan change its behaviour when button is switched on or off.
Identity of an object:-
As the name suggest , identity is nothing but something unique in an object through which an object can be recognized very easily.
For example:
An employee working in an organization can be easily identify by his employee id.
So,employee id acts as an identity of an employee in that organization.
Responsibility of an object:-
The responsibility of an object is the role it serves within the system.
For example:
the responsibility of an employee is to carry out the work given and get the salary.
Done with the talking of object , let's continue with our third concept of object oriented programming..
3.Inheritance :
Inheritance is the process by which one object can acquire the properties of another object.Inheritance has a 'is-a' kind of hirarchy.
For example:
vehicle can be categorize in two wheeler , three wheeler,four wheeler and again two wheeler can be categorize in geared and no geared , so now let'a create a hirarchy geared and non geared 'is-a' two wheere and two wheeler 'is-a' vehicle.
Note:
multiple inheritance is not applicable in .net. Only multilevel inheritance is applicable.
4. Polymorphism:
'poly' means many and 'morph' means forms in short polymorphism means many forms. Technically if i will say then , polymorphism is nothing but the ability of different types of related objects to respond to the same message in their own ways is called polymorphism.
this is very interesting for those who are new to this field and those who want gain knowledge in this field great keep it upppp
ReplyDelete