Showing posts with label Interview questions abstract class. Show all posts
Showing posts with label Interview questions abstract class. Show all posts

Thursday, 21 July 2016

Interfaces vs Abstracts

Abstract classes and Interfaces plays a major role in making our solution design. I had some time to analyse the best fit for business scenarios and differences.
Interfaces vs Abstracts:
  • Abstract classes specify the commonality in frame and function between multiple classes
  • Interfaces provide a frame for multiple class.
  • Abstract class contains member definition, Interface can only hold declaration.
  • Methods in a interface should be always defined in the derived class, but its not mandatory in abstract class.
  • Abstract classes can be used with classes which share same functionality
  • Interfaces can be used with classes that share different functionalities but similar blueprint.
  • Interfaces are used for dependency inversions and loose coupling
There is an interesting article from Microsoft regarding the same. Please refer https://msdn.microsoft.com/en-us/library/scsyfw1d(v=vs.71).aspx