其中哪一个会被认为是更好的编码习惯?这些都达到了相同的结果(显然是一个非常简单的例子),但我不知道尝试和维护功能可移植性是否更好。
1
Public Sub myFunction()
classInteger = GetLength(classString)
End Sub
Public Function GetLength(ByVal localString As String) As Integer
localInteger = localString.Length
Return localInteger
End Function
2
Public Sub myFunction()
GetLength(classString)
End Sub
Public Sub GetLength(ByVal localString As String) As Integer
classInteger = localString.Length
End Sub
3
Public Sub myFunction()
classInteger = GetLength()
End Sub
Public Function GetLength() As Integer
localInteger = classString.Length
Return localInteger
End Function
4
Public Sub myFunction()
GetLength()
End Sub
Public Sub GetLength() As Integer
classInteger = classString.Length
End Sub