"Armin Zingler" <az*******@freenet.deha scritto nel messaggio
news:%2****************@TK2MSFTNGP05.phx.gbl...
>Nothe that is a bad practice returning nothing for an array or a
collection. If the code is your you'd better return an empty array
or a collection with 0 elements.
If there is nothing to return why not return nothing? Sometimes Nothing
expresses something different from an empty array. I think it depends on
the
purpose of the function whether it makes sense to return Nothing.
Simply because it is ambiguos for the developer that will use that code.
He won't know if the function will return something or not and force him to
overkill code to test useless condition such as
If Not array Is Nothing Then
If array.Lenght 0 Then
Else
' error
Endif
Else
' error
Endif
resulting in less readable code, less performances and so on, and if Him
forget/don't know that the array can be nothing the app will crash.
This is the same reason for that someone suggest to not return nothing for a
derived class in a factory pattern but an istance of MyInvalidClass.
But everyone can choose its way to be "not CLS compliant" :)