Monday, 4 February 2019

Why should we use Interface where as we can get the same functionality by declaring and defining the methods in a class ?

The main purpose of the interfaces is that it makes a contract between the interface and any other class that implements that interface which makes your code decoupled and allows expandability.

 Using interface-based design concepts provides loose coupling, component-based programming, easier maintainability, makes your code base more scalable and makes code reuse much more accessible because the implementation is separated from the interface. Interfaces add a plug and play like architecture into your applications.

  1. It is used to achieve total abstraction.
  2. Since C# does not support multiple inheritance in case of class, but by using interface it can achieve multiple inheritance.
  3. It is also used to achieve loose coupling.
  4. Interfaces are used to implement abstraction.

No comments:

Post a Comment