Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting null value on Integer
Message
From
31/01/2016 04:41:39
 
 
To
30/01/2016 10:54:59
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01630133
Message ID:
01630455
Views:
64
>>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.....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform