G
Guru
Miha Markic said:You should simply test for the length of Item.SomeProperty beforehand
You can't read code, can you?
nLen = PerformSomeReallyWeirdCalculation(Item.SomeProperty)
How do you predict the value of nLen from the value of
Item.SomeProperty.Length?
- it is way cheaper than using try/catch.
Booleshift. A single equality comparison consumes a minimum of two CPU
cycles. In the 200,000 object scenario given, your lazy, unthinking approach
would add at least 400,000 CPU cycles to the processing time merely for the
purposes of an off chance intercept of an invalid value in data that you
have no control over.
I really do hope you are not employed as a programmer anywhere. A Try/Catch
is logically equivalent to a single If/Then statement... If
SomethingGoesWrong Then Go There... Prove that a single Try/Catch is more
expensive than 400,000 potentially unnecessary equality comparisons.
The only situation when exceptions might come handy are recursions.
LMAO - what is so special about the act of recursion that it might be
conducive to using Try/Catch blocks? Or do you merely hope that I will
unquestioningly accept your idiotic assertions?
And if you try to answer the former question, I strongly recommend you
inspect your answer for extreme stupidity involving any of your attrocious
programming practices before posting it.
Dim sw As New Stopwatch
Dim nCount As Integer
sw.Start()
For nZ As Integer = 1 To 2000000
If nZ = -1 Then
Exit For
Else
nCount += 1
End If
Next
sw.Stop()
Console.WriteLine(sw.ElapsedMilliseconds)
sw.Reset()
sw.Start()
Try
For nz As Integer = 1 To 2000000
nCount += 1
Next
Catch ex As Exception
Stop
End Try
sw.Stop()
Console.WriteLine(sw.ElapsedMilliseconds)
sw.Reset()
sw.Start()
For nz As Integer = 1 To 2000000
nCount += 1
Next
sw.Stop()
Console.WriteLine(sw.ElapsedMilliseconds)
11
8
8
Weren't you saying something about Try/Catch being more expensive? Hmmm?
<SNICKER>