I'm designing a new application and I'm undecided if I should fill my object properties on the constructor
Public Sub New(UserId as integer)
' get database values
dr = DataReader
Me.FirstName = dr.fields(0)
Me.LastName = dr.fields(1)
End Sub
Or create a factory with a method for each object type?
Public Function getUser(UserId as integer) as User
Dim myUser as new User
' get database values
dr = DataReader
myUser.FirstName = dr.fields(0)
myUser.LastName = dr.fields(1)
return myUser
End Function
I realize that the code is rough, but I'm hoping it's enough to get my point across. I've see both implemented and not sure what the long term pros and cons are.
Specifically, I'm using VB.NET, if it matters.