Reputation: 438
I've often wondered. In terms of "best practice" when writing a Function, be it Local or in a Module / Class, it is better to use:
Public Function WhichIsBetter(ByVal tmpUser As String, _
tmpPassword As String) As Boolean
'Do something
End Function
Or
Public Class User
Public Property tmpUser As String
Public Property tmpPassword As String
End Class
Public Function WhichIsBetter(ByVal tmpUser As User) As Boolean
'Do something
End Function
Upvotes: 1
Views: 64
Reputation: 26434
If no prior analysis has been done on code architecture, I would always start with ByVal tmpUser As String, tmpPassword As String
signature and see how code evolves.
If you find yourself passing tmpUser
and tmpPassword
around very often, i.e. every function has a signature of these parameters + something else, chances are you need to be passing a User object instead. Consider using an object even more, if you happen to be adding the same parameter to multiple functions often.
Upvotes: 1