An important Object Oriented Programming (OOP) concept utilized by Shining Star is the use of Interfaces.
Below are a few simple examples of how we use this concept in our programming to create cleaner, reusable code and hide unnecessary details:
Interfaces
An Interface is used in OOP to define a group of functions, methods, properties, etc. that a struct or non-abstract class is required to implement in order to provide consistency and continuity to our libraries and code.
In a dating site I designed, to handle the dating questionnaire, I used public interfaces to define the requirements for classes that implemented this interface:
Public Class QACheck
Inherits ShiningStarControl
Implements IQACheck
Public Sub Setup(ByVal checkText As String) Implements IQACheck.Setup
Try
chkAnswer.Text = checkText
Catch ex As Exception
SendError(ex.Message)
End Try
End Sub
Public Property GetSetAnswer() As Boolean Implements IQACheck.GetSetAnswer
Get
Return chkAnswer.Checked
End Get
Set(ByVal Value As Boolean)
chkAnswer.Checked = Value
End Set
End Property
...
And those in turn also implement the IQACheck Interface:
Public Interface IQACheck
Property QuestionValueName() As String
Property QuestionValueQuestion() As String
Property GetSetAnswer() As Boolean
Property QAFieldId() As String
Sub Setup(ByVal checkText As String)
End Interface
Implements
To actually utilize these interfaces, we then use the "Implements" statement:
Public Class QACheck
Inherits ShiningStarControl
Implements IQACheck
Public Property GetSetAnswer() As Boolean Implements IQACheck.GetSetAnswer
Get
Return chkAnswer.Checked
End Get
Set(ByVal Value As Boolean)
chkAnswer.Checked = Value
End Set
End Property
Public Property QuestionValueName() As String Implements IQACheck.QuestionValueName
Get
Return lblQuestionValueName.Text
End Get
Set(ByVal Value As String)
lblQuestionValueName.Text = Value
End Set
End Property