I am developing a COM addin for Microsoft Excel, using VB.Net. I wrote a class to represent a worksheet that contains certain elements. Let's say for example it has a ListObject. I create a property for the ListObject like this:
Public Class MySheet
Private myTable as Excel.ListObject
Public Property Table() As Excel.ListObject
Get
Return myTable
End Get
Set(ByVal value As Excel.ListObject)
myTable = value
End Set
End Property
I then have properties (in MySheet class) that represent attributes of the ListObject, for example:
Private myTableStyle As String
Public Property TableStyle As String
Get
Return myTableStyle
End Get
Set(ByVal value As String)
myTableStyle = value
Me.Table.TableStyle = value
End Set
End Property
The reason I have it set up this way is so that in my main code I don't have to update two properties every time I want to change the style (the TableStyle property of the MySheet class AND the TableSTyle property of the ListObject). So in my main code I can have:
Dim MySheetObject As MySheet = New MySheet()
MySheetObject.Table = SomeListObject
MySheetObject.TableStyle = "TableStyleMedium4"
That last line then stores both the string value as a property of the MySheet object and changes the TableStyle property of the ListObject in Excel.
Is this OK, or is it breaking some coding principle?