I'm quite new to OO programming. I'm building a class in VB.NET and I want properties to be grouped within certain categories. Should the categories be declared as a Subclass or as a Property? In other words, which of the two approaches is better?
Class Tree
Property Trunk As Trunk
Property Leaves As Leaves
End Class
Class Trunk
Property Color As String
Property Diameter As Integer
End Class
Class Leaves
Property Color As String
Property Width As Integer
Property Height As Integer
End Class
or
Class Tree
Class Trunk
Property Color As String
Property Diameter As Integer
End Class
Class Leaves
Property Color As String
Property Width As Integer
Property Height As Integer
End Class
End Class
In both cases, I will use the instance of Tree
with something like myTree.Trunk.Color = "Red"
, but which one is considered as a best practice?
Thank you for your help.