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.
- Data Hiding
- 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:
public int Add(int number_1,int number_2)
public int Add(double number_1,double number_2)
public static void Main()
Sum mysum_obj=new Sum();
Console.WriteLine("Sum of two integer number is "+mysum_obj.Add(1,2));
Console.WriteLine("Sum of two float number is "+mysum_obj.Add(1.1,2.2));