C# – First steps with C# and .NET – part 028 .

A programming model which is mainly organized around the objects is called Object-Oriented Programming or the Programming named OOP.
There are five basic pillars or concepts in OOP.

  1. Encapsulation
  2. Data Hiding
  3. Specialization
  4. Polymorphism
  5. Division of Responsibility

Encapsulation is a process of binding data members (variables, properties) and member functions (methods) together.
Data Hiding refers to the class’s internal data is not accessible from outside the class.
Specialization allows you to establish hierarchical relationships among your classes.
Polymorphism is the process in which an object or function takes different forms.
Division of Responsibility reflects the program design and how will work in terms of the development of the team.
All these pillars/concepts have advantages and disadvantages in development.
The advantages and disadvantages result from the mode of interconnection and development.
An advantage of encapsulation is the property of hiding the internals of the object or allowing access to it through only member function protects objects integrity by preventing users from setting the internal data or the component.
This allows us to avoid an invalid or inconsistent state of the object.
The inheritance advantage is code re-usability.
An advantage of polymorphism is the use of the overload method.
Let see an example with polymorphism:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.