locked
MVP Interface variable RRS feed

  • Question

  • User462798223 posted

    Hi,

    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
    End Interface


    Public Class Presenter
        Dim pview As IView

        Public Function buildtext() As String

        End Function
    End Class

    Rgds

    vg

     

     

    Friday, January 22, 2010 12:01 PM

Answers

  • User-1379894896 posted

    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).

     

     

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 23, 2010 2:27 PM