Think of an interface, such as contract , you specify what you expect from consumers of this interface.
An abstract class, on the other hand, is useful if you have some code that needs to be implemented for the class, but not all. And you can declare abstract methods for parts that must be implemented by subclasses of the abstract class. Remember that abstract methods must be performed by subclasses, but you can also provide your own code inside the class itself through regular private / public / protected / etc. Methods
So, if you are just writing a contract that you want to implement subclasses, then think about the interface. But if you write something more than a "template" where you can have some of the method implementations (but not all) that will be common to all child implementations, then you should think about an abstract class.
dcp
source share