Hi Gurus,
What is the benefit of using Interface Inheritance or Implements and When to use it?
Thanks a lot in advance.
MsJane
Printable View
Hi Gurus,
What is the benefit of using Interface Inheritance or Implements and When to use it?
Thanks a lot in advance.
MsJane
Pros:
Private implementation forcing the caller to use only the interface provided.
Multiple interface support without name collisions.
Polymorphism.
And, arguably, code reuse.
Cons:
wasted code since VB doesn't distinguish between a class and an interface.
Quite a few more caveats better explained by Matt Curland in his book Advanced VB 6(http://www.powervb.com).
When to use:
A matter of taste and probably too many cases to be explained here. Use your imagination. Think of a problem that could be solved by multiple implementations of the same interface.(e.g. Plugins) You could still write effective VB code without ever having to use Implements.
Software is like sex, it's better when it's free - Linus Torvalds
Software is like sex, it's better when I get paid for it. - me
Hi,
You can use impelements after u defined an
interface in Vb.This class will have only method
defenitions not the actual methods.
U may use this if u want some classes to
necessarly use an interface.
So after impelementing an interfece earlier defined in ur class by using IMPLEMENTS keyword it wont allow compilation without writing methods in the impelemented interface.
Regards