Thursday, 7 July 2016

C# oops Concepts

Object orientation involves splitting the software system into component parts and arranging the parts in a hierarchy.
An object-oriented program consists of classes and objects.
Objects communicate with each other by using messages.
Object orientation is a software development methodology that relates to the real world.
An object is the core concept involved in object orientation.
An object is the representation of a real world entity or concept.

Object-Oriented Programming is a methodology to design a program using classes and objects. It simplifies the software development and maintenance.
Following are the object orientated programming concepts.
  • Object
  • Class
  • Inheritance
  • Polymorphism
  • Abstraction
  • Encapsulation
Object - An object means a material thing that can be presented physically. Any entity that has state and behavior is known as an object.
Class - A class consists of a blueprint of objects that share a common structure and behavior.
Inheritance - Inheritance is a property of Object-oriented programming that enables a derived class to inherit the members of the base class.
A class that inherits or derives attributes from another class is called the derived class.
The class from which attributes are derived is known as the base class.
The base class is also known as super class, whereas the derived class is known as sub class.

Polymorphism- The word Polymorphism means of many forms. Polymorphism is an object-oriented programming concept that refers to the ability of a variable, function or object to take on multiple forms.
Abstraction- Hiding internal details and showing functionality is known as abstraction.
Abstraction lets you focus on what the object does instead of how it does it.
Abstraction is the process of hiding the working style of an object, and showing the information of an object in understandable manner.



Encapsulation-Binding (or wrapping) code and data together into a single unit is known as encapsulation.
Encapsulation is like enclosing in a capsule. That is enclosing the related operations and data related to an object into that object.

Difference between Abstraction and Encapsulation

Abstraction
Encapsulation
1. Abstraction solves the problem in the design level.
1. Encapsulation solves the problem in the implementation level.
2. Abstraction is used for hiding the unwanted data and giving relevant data.
2. Encapsulation means hiding the code and data into a single unit to protect the data from outside world.

3. Abstraction lets you focus on what the object does instead of how it does it
3. Encapsulation means hiding the internal details or mechanics of how an object does something.
4. Abstraction- Outer layout, used in terms of design.
For Example:-
 Outer Look of a Mobile Phone, like it has a display screen and keypad buttons to dial a number.
4. Encapsulation- Inner layout, used in terms of implementation.
For Example: - Inner Implementation detail of a Mobile Phone, how keypad button and Display Screen are connect with each other using circuits.



Advantage of Object Oriented programming

Realistic modeling:-The object-oriented approach models the real world.

Example
Reusability:-The object-oriented approach allows you to reuse existing classes or objects.

Example
Modularity:-The object-oriented approach allows objects to be maintained independently of other objects.

Example

Flexibility to change:-The object-oriented approach allows you to create a new class by adding some new features to an existing class.


Information hiding:-The object-oriented approach allows limited access to information.








No comments:

Post a Comment