[dba-VB] Fail Fast

Gustav Brock Gustav at cactus.dk
Fri May 23 13:35:37 CDT 2008


Hi Shamil

I like that approach, actually I once had the idea that error messages should be localized ...

The article mentions an example of the type:

  On Error .. let value of variable x = 10

That is plain bad code in my opinion and makes a discussion on what approach to use difficult.

However, when I think about it - encouraged by your posting - in Access I don't use error handling that much and mostly on a general level to catch disk/network errors and the like. I run so many tests on various user inputs during development that the code is virtually bug free. Well, of course not, but the level is so low that it doesn't pay off to do more about it. In most installations of our software we see zero errors a year caused by the software itself. Errors met are caused by network or hardware malfunction.

With Visual Studio it is different but similar. I've found that when an error is raised, the message is so informative that I don't need more information. Also the stack window is a great help and - again - the IDE of VS demonstrated its superiority at a surprising level when I noticed the first time that code lines with jumps to other code modules are highlighted. Of course I include a try/catch here and there but I prefer to check for potential errors - like a lost connection before running a major update routine.

Further, to my surprise, VS lets some errors pass which don't have to stop the code, indeed formatting errors for empty strings. This is certainly an indication of a value not intended, so I turned on the setting that will raise an error in such cases. Put a check mark in Thrown here:

Debug, Exceptions ..., Common Language Runtime Exceptions, System, System.FormatException

/gustav


>>> shamil at smsconsulting.spb.ru 20-05-2008 21:16 >>>
Hi All,

Would you like to minimize lengthy debugging sessions - then use "Fail Fast"
approach!:

http://www.martinfowler.com/ieeeSoftware/failFast.pdf 


It sounds very tempting I must say, and the author's arguments are good and
practical, but you can find that proposed approach is rather different from
On Error Resume ... or On Error GoTo ... used in almost all and every
function/sub/property approach recommended as professional programming style
in VBA/VB6...

To catch up inevitable bugs and gracefully present them to the users author
recommends using global error handlers...
 
Do you feel any flavors with the proposed approach? Please share them here.

I do not (I could have missed some), and I do plan to adapt to this
approach: I used like that in C ages ago but VB6/VBA programming made me a
bit "paranoid" and I did widely use On Error... VB6/VBa construction...

In my understanding proposed subject approach results in streamlined coding
with less code lines, less comment lone as well as less time spent in long
debugging sessions: of course "there is no free cheese in this world" and
proposed approach implies using Test Driven Development but anyway overall
result is positive with (significant) development and support time savings
as author states (based on his broad development experience) in this subject
article and in his excellent book "The Art of Agile Development" he
coauthored with Shane Warden...

Thank you.

--
Shamil





More information about the dba-VB mailing list