I have a class definition that I’ve seen other define properties that return collections of objects.
Public Property GetAllAdults() as Adults
...
End Property
I made the argument that this should be a method in the class, because it doesn’t define an attribute of the class, and could not be extended with parameters. Is/Are there reasons why this should be defined as a property vs. a function?
I would argue that since this is a simple Getter rather than something that actually performs some action, it is much better suited as a Property.
It’s name should be changed to reflect the fact that it is a property, thus changing from GetAllAdults() to Adults.
Furthermore, I would also argue that since there is only a getter…you might think the collection is read-only, which is not the case. To make it truly read-only, you should expose the property as a ReadOnlyCollection (if possible):