... leaving "catch" block empty in a try-catch-end
try block to ignore exceptions which i don't approve of course
Why not? Say some code is looping through 200,000 business objects,
computing the starting position of a substring of some property in each and
every business object. Now assume that the starting point of one solitary
substring in the entire list of 200,000 business objects is -1, i.e. one
item in 200,000 is invalid, say due to operator error on some external
system that your code has no control over... now, for some undefined
business reason, the code is not interested in items that are invalid so the
code will drop those items... Also assume that, with you as
programmer-in-chief of Major Corporation X, your distressed employer has
threatened to fire your scrawny, incompetent butt if you don't improve the
performance of your code...
For Each Item As SomeType In SomeHugeListOfStrangeBusinessObjects
nLen = PerformSomeReallyWeirdCalculation(Item.SomeProperty)
iStart = PerformSomeVeryStrangeCalculation(Item.SomeOtherProperty)
Try
SomeOtherExoticList.Add(Item.SomeProperty.Substring(iStart, nLen)
Catch ex As Exception
' Do nothing... drop this item, we don't want it.
End Try
Next ' Item
That, Mister Unapproving-of-Empty-Catch-Clauses, is by far and away, much
quicker than doing 200,000 equality comparisons on iStart just to trap the
occasional, freaky business object; millions of CPU cycles quicker, in fact.
So, now that you have been given 200,001 valid reasons (200,000 equality
comparisons plus your job security) in favour of using empty Catch clauses,
please provide one single, solitary but equally valid reason for not using
them.
Thank you.