Home » Education, Google, Tips and Tricks and Wordpress Blog

What is Object Oriented Programming (OOP) and its various features with respect to C#

Submitted by Miss Neha Ashani on Monday, 8 February 2010No Comment
Email This Post Email This Post   ·   Print This Post Print This Post   ·   Tweet This  ·   Stumble it!  ·   Add To del.icio.us

What is Object Oriented Programming (OOP) and its various features with respect to C#

Object-oriented Programming (OOP) was introduced to overcome flaws in the procedural approach to programming, such as lack of re-usability and maintainability. OOP has a number of features that makes it different from standard procedural languages. Some of these features are as follows:-
1.    It emphasizes on the data rather than the procedures.

2.    It can hide certain critical data to prevent access by any unauthorized section.

3.    It allows new data and functions to be easily added whenever required.

Object-oriented programming has various advantages over procedural programming. Some of these are:

1.    It enables code re-usability.

2.    It provides a clear modular structure for programs, which makes it good for hiding data.

3.    It enables the user to maintain and modify existing code easily as new

Objects can be created by making minor changes to existing ones. Object-oriented programming provides 4 features that make it distinct and powerful as compared to procedural programming. These features are:-

  • Abstraction

Consider an example of a car that consists of a number of individual parts. Explaining the details of each and every individual part to the user can be difficult and complex. Further, the user might not be able to understand such technical details. However, by considering the role of the user in using the car, only the necessary features of the car can be explained. This is called abstracting information about an entity. Similarly in C#, the feature of describing only the relevant information about an object is called abstraction.

  • Encapsulation

Consider an example of an ATM machine, the user inserts the ATM card and enters his/her pin number. If the pin number is wrong, an error message is displayed. Otherwise, the pin number is accepted and the process continues. However, the login process consists of three steps. They include:-

1.    Reading the ATM card number.

2.    Validating the card and pin numbers.

3.    Receiving the result of whether the login is valid or not.

The validation process is not visible to the user, as it is hidden so that it cannot be accessed or modified for security reasons. Similarly in C#, certain critical details of a class can be hidden from the other classes. This feature of data hiding is termed as encapsulation.

  • Inheritance

Consider an example of a family of 3 members having a mother, father and their daughter named Jill. Jill’s father is tall and dark and his mother is short and fair. Jill is fair and tall, so he is said to have inherited the features of the father and mother both. Similarly, in programming languages like C#, inheritance is the process by which an object of one class acquires the characteristics and behaviors of the object of another class.

A class can inherit an existing built-in class or a user-defined class only if there exists a relation between the two classes. These relations are:

1.    Is a: Student is a human being. Here, the Human class can be the base class for the Student class.

2.    Type of: Mammal is a type of an animal. Here, the Animal class can be the base class for the Mammal class.

3.    Part of: Gears are part of a car. Here, the Car class can be the base class for the Gears class.

  • Polymorphism

Consider an example of microwave oven. The oven can be used to warm food or bake items such as cake and biscuits. Thus, it is seen that the same device can be used for performing different tasks.

Similarly in C#, there can be multiple methods declared with the same name either with different parameters or body. Methods with same name and different parameters are known as overloaded methods whereas methods with same name but different body are known as overridden methods.

Thus OOP has various advantages over procedural programming. Some of these are:

1.    It enables code re-usability.

2.    It provides a clear modular structure for programs, which makes it good for hiding data.

3.    It enables the user to maintain and modify existing code easily as new objects can be created by making minor changes to existing ones.
I Hope that this article has given you an clear idea about OOP. For any queries please feel to write to me and do post your valuable comments it will help me to understand your needs better. Till then keep blogging.

[Post to Twitter] Tweet This Post 


Get FREE news headlines on What is Object Oriented Programming (OOP) and its various features with respect to C# by email, Sign up now :

addtomyyahoo4 Subscribe in NewsGator Online Subscribe with Bloglines 
Add to Google 

Email This Post Email This Post   ·   Print This Post Print This Post   ·   Tweet This  ·   Stumble it!  ·   Add To del.icio.us



Take your books, blogs and newspapes with you on the go! Find out how inside! Click Here

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.