Monday, June 22, 2020

C# Tutorial: 13 - Object Oriented Programming

Tutorial: 13 - Object Oriented Programming (OOP)

Object Oriented Programming is backbone of .NET framework. The key idea behind Object Oriented Programming is to create classes and objects which contains fields and methods. There are several advantages to object oriented programming:

  • It is faster and easier to execute
  • It provides clear structure for the programs
  • It helps to makes the code easier to maintain, modify and debug
  • It helps to create reusable applications.
The four pillars of Object Oriented Programming are:
  • Abstraction
  • Inheritance
  • Polymorphism
  • Encapsulation
Abstraction
Exposing only information which is relevant and essential to user and hiding certain details from the user is referred as Abstraction. Abstraction can be achieved using either interfaces or abstract classes. We will discuss abstract classes and interfaces in later tutorials. For now just understand basic idea.

Inheritance
The key idea behind inheritance in to inherit the fields and methods from one class to another.  The class which inherits the fields and methods is called child/derived class and the class from which we inherit fields and methods is called parent/base class.

Polymorphism
When classes have relation among them using inheritance or they are linked with each other using inheritance, polymorphism comes in action. This allows to perform single operations with different ways.

Encapsulation
In object oriented programming, encapsulations is referred to prevention of access to implementation. Encapsulation is achieved using access specifiers which we have already discussed.

In next tutorials, we will discuss these concepts in details.

No comments:

Post a Comment