Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting null value on Integer
Message
De
31/01/2016 04:41:39
 
 
À
30/01/2016 10:54:59
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01630133
Message ID:
01630455
Vues:
56
>>Wouldn't this do the same job? :
   Public Function EmptyDate(ByVal tdDate As Object) As Boolean
>>        If tdDate Is DBNull.Value Then Return True
>>        Return CType(tdDate, Date) = New Date(1899, 12, 30)
>>    End Function
>
>Yes, it would. But, good practice I am using is to:
>
>Not have a return to calculate something
>Not put everything into on line (this breaks on evolving when time comes and makes it extremely difficult to understand)
>
>I also need to keep multiple backend supports.

I think it's just a matter of preference. I'd find my code more readable than yours :-}

FWIW, here's what 'Code Complete' says on the subject:

(a) Minimize the number of returns in each routine. It's harder to understand a routine if, reading it at the bottom, you're unaware of the possibility that it returned somewhere above.

(b) Use a return when it enhances readability. In certain routines, once you know the answer, you want to return it to the calling routine immediately. If the routine is defined in such a way that it doesn't require any cleanup, not returning immediately means that you have to write more code.

I'd argue that 'b' applies here.....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform