Last post Jan 23, 2010 02:27 PM by Caspar Kleijne
Jan 22, 2010 12:01 PM|do.exec|LINK
What is the purpose of interface variable?
I am stumped by seeing that interface variable, what is the technique behind it?
Public Interface IView
Property slbl() As String
Public Class Presenter
Dim pview As IView
Public Function buildtext() As String
Jan 23, 2010 02:27 PM|Caspar Kleijne|LINK
An interface is a "contract" it ensures the calling method that the function or method that is called is "absolutely there".
The can be used to gracfully expose functions or subs to the "outside world".
Therefore it is ensured that a class acts accordingly as designed by the Interface.
Real life Example:
When call to a bank (Class) you speak to an employee(Sub) trough telephone line.
At lunchtime the employee leaves. But you can still call the Bank. The telephone ensures that. It can be seen as an interface.
Even if the bank doesn't answer the phone you can always Call (use that sub).
If you spoke the Employee directly instead of trough the phone, and he suddenly left, you would be confused (code breaks).