R
Richard Brown
Ok, now I am truely going nuts... probably why I didn't use the Class
Builder in VB6 extensively.
But, being the 'proper programmer' that I should, I'm trying to bite the
bullet and build classes for each of my 'entities' that operate within the
program, ie, passenger, vehicle, etc. Then seperate UI classes that link to
these. (Partially, because eventually several add-ons will be able to reuse
the code in the data classes).
My question is this....
Is there any SHORTER way to define properties in a class than....
Public Class Passenger
Private sFirstName As String
Public Property FirstName As String
Get
FirstName = iFirstName
End Get
Set
iFirstName = FirstName
End Set
End Property
...
End Class
Obviously, with 10-20 fields in the class, you end up with, oh 100 lines of
code... doing not much more than setting and retrieving variables. Which,
if that was the case, would be fine, but I'd also like to set a 'dirty' flag
if any of them are reset, some business logic will be in some fields, etc.
So, is there a 'short-form' for properties, OR, is there a way to 'fake'
properties, that is something to do with the reflection library to simulate
properties, but have them all serviced by only a couple property functions
(ie, use a collection to store the values, and one property service function
to check them/assign them/perform other logic).
This probably sounds lazy of me, but Im dreading going through and creating
20-30 data class libraries with 20-30 fields each ---- just tell me it isn't
so.
Builder in VB6 extensively.
But, being the 'proper programmer' that I should, I'm trying to bite the
bullet and build classes for each of my 'entities' that operate within the
program, ie, passenger, vehicle, etc. Then seperate UI classes that link to
these. (Partially, because eventually several add-ons will be able to reuse
the code in the data classes).
My question is this....
Is there any SHORTER way to define properties in a class than....
Public Class Passenger
Private sFirstName As String
Public Property FirstName As String
Get
FirstName = iFirstName
End Get
Set
iFirstName = FirstName
End Set
End Property
...
End Class
Obviously, with 10-20 fields in the class, you end up with, oh 100 lines of
code... doing not much more than setting and retrieving variables. Which,
if that was the case, would be fine, but I'd also like to set a 'dirty' flag
if any of them are reset, some business logic will be in some fields, etc.
So, is there a 'short-form' for properties, OR, is there a way to 'fake'
properties, that is something to do with the reflection library to simulate
properties, but have them all serviced by only a couple property functions
(ie, use a collection to store the values, and one property service function
to check them/assign them/perform other logic).
This probably sounds lazy of me, but Im dreading going through and creating
20-30 data class libraries with 20-30 fields each ---- just tell me it isn't
so.