I realise this subject has been covered in an earlier thread, but I would like to just ask the same question coming from a differant angle.Abstract classes can have empty(abstract methods),or concrete methods .interfaces are abstract but cannot contain any code apart from empty methods(abstact) and whereas with subclasses being only able to access one abstract class ,subclassess can implement many interfaces at differant levels .I would like to add what I think is happening with regards to why these differant classes are used and then someone may point me in the correct direction.
Related subclasses use abstract classes to link objects together of a related type .rather than having classes seperate at birth they are connected in a relationship where the parent has the same genes as the children. All the abstract methods in the parent form a signature which the child can impliment and override to form it`s own implimentations of the methods.So in reality what is happening is a common ground between all subclasses is being established.
Interfaces enable multiple sharing by subclasses but allow only method definitions and no implementation of any sort.
just to add to my thread above . Using abstract and interface seems pretty straight forward in an explanation of implimentation uses but in what circumstances can you measure where such methods should be used
in the app i'm developing (home stuff) i have: the boss, the private care (prv) client and the public care client (pub). In order to have everything properly established, an agreement (contract) is made with date, which client, service type, cost, etc.
I came up with inheritance, since both contracts between boss and prv or boss and pub have so much in common. So i created a superclass AbrstractContract from which PrivateContract and PublicContract inherit;
and abstract precisely because i've a method cost() that should be implemented by every subclass in its own way. (i know i could as well have defined the method in superclass and then having each children overriden it)
As to interfaces, the idea is having related or unrelated classes having a common set of behaviour.