Thursday, July 28, 2016

Abstract Class VS Interface in C#

An interface is more supple from the client's perspective:
any class can implement as many interfaces as it wants to. Unfortunately, an interface is more rigid from the developer's perspective: it can't be easily changed and it does not support any kind of reusability.

An abstract class is supple from the developer's perspective:
it supports reusability, it supports encapsulation, it can be extended easily without breaking existing clients.
With all that said, we can conclude the interesting rule of thumb: use abstract classes for building internal APIs and use interfaces for providing external points of extension.

No comments:

Post a Comment

Code Formater

Paste Here Your Source Code
Source Code Formatting Options
1) Convert Tab into Space :
2) Need Line Code Numbering :
3) Remove blank lines :
4) Embeded styles / Stylesheet :
5) Code Block Width :
6) Code Block Height :
7) Alternative Background :
Copy Formatted Source Code
 
Preview Of Formatted Code