Note that there are some explanatory texts on larger screens.

plurals
  1. PORecommendations for Abstract Classes vs Interfaces
    primarykey
    data
    text
    <p>I know the difference between interface and abstract class. Now I would like to know where exactly i need to use interface over abstract class, vice versa.</p> <p>The article i referred <a href="http://msdn.microsoft.com/en-us/library/scsyfw1d%28v=vs.71%29.aspx" rel="nofollow"><code>Recommendations for Abstract Classes vs. Interfaces</code></a></p> <p>In that</p> <p>Here are some recommendations to help you to decide whether to use an interface or an abstract class to provide polymorphism for your components.</p> <blockquote> <ol> <li><p>If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface.</p></li> <li><p>If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes.</p></li> <li><p><strong>If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.</strong></p></li> <li><p>If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.</p></li> </ol> </blockquote> <p>I am not sure about the point #3. Do i need to place all the small functions of my component into interface? </p> <p><em><strong>Any real world/understandable example which will help me to choose each?</em></strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload