Abstract class vs interface continued...
Hope to clarify some questions/confusions on my previous post on
Abstract class Vs Interface. Here I am trying to look at the conceptual difference only.
"Of course an interface defines a type": Interesting thought. I would appreciate examples to have a better understanding of the statement.
If interface here refers to the java interface (
Walkable as in my previous post), the behaviour
walk specified by the interface is not sufficient to define a class/type of objects referred by the
Walkable interface.
If interface is used to refer the messages you can send to an object, I would say the type defines the interface.
When modeling a problem say
BankAccount,
we do not start from
deposit(...) , withdraw(...) interfaces to define the type
BankAccount. We would rather start from the
BankAccount.
However when we do classification of objects we do start from the interfaces of the objects to create a class/type.
"just wanted to know if we cannot say "walk" as a behavior/type?":Perfect to say,
walk is a behaviour. However not sufficient to define a class/type of objects referred by the
Walkable interface as mentioned above.