learning
Active member
If I have a class defined as shown below. The class itself isn't important. Just that is has private members interfaced through public properties and functions :
Then I create another class that uses an instance of the previous one :
My question is, should I be declaring SomeData1-3 Public or should it be Private with Public additional properties that expose the members of DataArray? Or, something else.
Thanks
VB.NET:
Public Class DataArray
Private _dataArr() As Single
Public Sub New(ByVal initialData As Single())
_dataArr = initialData
End Sub
Public Property Data(ByVal itemIndex As Integer) As Single
Get
Return _dataArr(itemIndex)
End Get
Set(value As Single)
_dataArr(itemIndex) = value
End Set
End Property
Public Function Max(ByVal lowIndex As Integer, ByVal hiIndex As Integer) As Single
Dim sortedData() As Single
sortedData = CType(Array.CreateInstance(GetType(Single), hiIndex - lowIndex), Single())
Array.Copy(_dataArr, lowIndex, sortedData, 0, hiIndex - lowIndex)
Array.Sort(sortedData)
Return sortedData(sortedData.GetUpperBound(0))
End Function
End Class
Then I create another class that uses an instance of the previous one :
VB.NET:
Public Class Class2
Public SomeData1 As DataArray
Public SomeData2 As DataArray
Public SomeData3 As DataArray
Private _someOtherData as Integer
Public Property SomeOtherData As Integer
Get
Return _someOtherData
End Get
Set(value As Single)
_someOtherData = value
End Set
End Property
.
.
.
End Class
My question is, should I be declaring SomeData1-3 Public or should it be Private with Public additional properties that expose the members of DataArray? Or, something else.
Thanks