Again Abstract class vs Interface...
While pairing with a fellow thoughtworker (
http://thoughtworker.in) we ended up discussing Abstract class vs Interface and he found this explanation useful.
A Class (abstract or not) defines a type while an interface does not.In my domain anything that can be drawn is a shape(including a point) and thus behaviour defines a type.
abstract class Shape{ public abstract draw();}In another domain which includes a Robots, Humans and Pets,
If I need to treat all objects that can walk similarly, I would like to have an abstract handle to of all the above and that ends up in a
interface Walkable{ void walk();} ...Robot implements Walkable{...}...Human implements Walkable{...}...Pet implements Walkable{...}and merely something that can walk does not define a type here. Its a mechanism to tie together otherwise unrelated types Robot, Human and Pet.