Balu
Posts: 3
Nickname: balus
Registered: Jan, 2004
|
|
Re: Difference between Interface and Abstract Classes
|
Posted: Jan 9, 2004 2:22 AM
|
|
Well, typically you would use an abstract class in cases where a functionality needs to be extended. ie, the sub class is extending something that exists but is not complete by itself. On the other hand you would use an interface to enforce a protocol.
One application I have seen of interface is as follows - If you had an application that required to do database transactions with different types of systems (ie. Oracle, IBM Legacy systems, etc), you could use an interface to mask the intricacies of connecting with the various systems from the developer by providing a common interface to all the systems, while the various implementations of the interface could have nothing to do with each other. In such a case you would have no use for abstract classes quite simply because it is not a common functionality that you are extending.
A case for using an abstract class could be for a banking application where CheckingAccount and SavingAccount could derive from an abstract BannkAccount class. Both the sub-classes would derive some common functionality from the BankAccount class and them add some of their own, and also BankAccount would not be complete by itself.
s.balu
|
|