Dec 29, 2015 04:53 PM|PatriceSc|LINK
No. Don't look at what can be done the same way with two different features. See rather the doc and see what is the unique benefit for each feature. From
"They are classes that cannot be instantiated, and are frequently either partially implemented, or not at all implemented."
So in short, unlike a regular class an abstract class allows:
- to get a compile time error if a 3rd party developer tries to use your class as is. The error message likely tells that you have to inherit from this class
- and similarly you can require the 3rd party developer to implement a particular method you were not able to provide (and again with a compile time error)
You could perhaps do that with regular classes but at least you would need to throw runtime exceptions to let know the developer about the missing implementation parts (and one by one only when his code tries to use it). You likely won't use that often but
its nice to have when needed (so when you want to provide a base class without being able to provide a full implementation and having to let a 3rd party developer to provide the implementation for the missing parts).
For example in .NET it is used for db access classes found in
A 3rd party developer can then easily inherit from those classes and see which methods needs to be implemented to create a provider for his own database system. And for some other method, a default implementation is already provided so that you don't have
to be concerned about that. You have just to deal with what is particular to how your database works.