8 abstract classes and interfaces

3,537 views

Published on

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,537
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
178
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

8 abstract classes and interfaces

  1. 1. Abstract classes & Interfaces Programming in C# tnngo2@gmail.com
  2. 2. Abstract Classes
  3. 3. Abstract Classes referred to as an incomplete base class cannot be instantiated, can only be sub-classed.
  4. 4. Implementation The subclass inheriting the abstract class has to override and implement the abstract methods https://gist.github.com/2373593
  5. 5. Inheritance
  6. 6. Purpose A subclass in C# cannot inherit two or more base class.
  7. 7. Interfaces contains only abstract members cannot implement any methods cannot be instantiated by default, all members have public as the access modifier cannot contain constants, data fields, constructors, destructor and static members
  8. 8. Implemetation https://gist.github.com/e63d1cf32b03cd888686
  9. 9. Mutiple Inheritance https://gist.github.com/7856dad9ccfe58aaa0da
  10. 10. Interface Inheritance An interface can inherit multiple interfaces but cannot implement them. https://gist.github.com/2374963
  11. 11. What difference between abstract classes & Interfaces?
  12. 12. Short Interface: contract only, no implementation, no instantiation Abstract class: contract, some implementation, no instantiation Interface specifying what the object can do Abstract specify what an object is
  13. 13. Similarities cannot be instantiated are implemented by the inheriting subclass can inherit multiple interfaces
  14. 14. Differences
  15. 15. Some stories
  16. 16. Recommendations
  17. 17. Multiple version of component => Abstract classfunctionality will be useful across a wide range of disparate objects => Interfacessmall, concise function bits of functionality => Interfacescommon, implemented functionality among all implementations ofyour component => Abstract class

×