DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 5 of 8 FirstFirst ... 34567 ... LastLast
Results 61 to 75 of 109

Thread: Correct Error Handling

  1. #61
    Karl E. Peterson Guest

    Re: Correct Error Handling

    Hi Liam --

    > Generators can
    > also be used as great training tools for new developers.
    >
    > For example, in the case of web page creation, do you think that FrontPage
    > is a useful tool? I do and so do a lot of other people that use it to generate
    > HTML.


    Ack! You're not suggesting FP, or *any* code generator should be used by newbies,
    are you? As a *training* tool??? Good grief. Yes, FP is incredibly useful, but
    *only* if you already know HTML. No way, any dev worth the effort needs to spend a
    year coding in Notepad before allowing software to code for him.

    > VB itself ships with a lot of useful wizards and templates that generate code

    ^^^^^^
    You misspelled "useless." HTH!

    Later... Karl



  2. #62
    Mike Culley Guest

    Re: Correct Error Handling


    Karl,

    >> VB itself ships with a lot of useful wizards and templates that generate

    code
    > ^^^^^^
    >You misspelled "useless." HTH!


    Very true. But I think this is why code generators have such a bad name.
    I can see several excellent uses for a code generator.

    Someone in VBPJ suggested writing a generator that added properties to a
    class/form/usercontrol - with the option of adding code to persist the property.
    Just like the VB property generator, but good. When adding a property to
    a control, you have to put code in 5 places (variable declare,Let,Get,ReadProp,WriteProp).

    Or how about a code generator that writes the code to create a database.

    Or one that writes code to verify a database.

    How else would these last 2 be done easily with a code generator?

    Michael Culley

    "Karl E. Peterson" <karl@mvps.org> wrote:
    >Hi Liam --
    >
    >> Generators can
    >> also be used as great training tools for new developers.
    >>
    >> For example, in the case of web page creation, do you think that FrontPage
    >> is a useful tool? I do and so do a lot of other people that use it to

    generate
    >> HTML.

    >
    >Ack! You're not suggesting FP, or *any* code generator should be used by

    newbies,
    >are you? As a *training* tool??? Good grief. Yes, FP is incredibly useful,

    but
    >*only* if you already know HTML. No way, any dev worth the effort needs

    to spend a
    >year coding in Notepad before allowing software to code for him.
    >
    >> VB itself ships with a lot of useful wizards and templates that generate

    code
    > ^^^^^^
    >You misspelled "useless." HTH!
    >
    >Later... Karl
    >
    >



  3. #63
    Karl E. Peterson Guest

    Re: Correct Error Handling

    Hi Mike --

    > Just like the VB property generator, but good.


    LOL! I'd like to see that, but don't anticipate it anytime soon.

    > When adding a property to
    > a control, you have to put code in 5 places (variable

    declare,Let,Get,ReadProp,WriteProp).

    Not to mention InitProps, eh?

    > Or how about a code generator that writes the code to create a database.
    >
    > Or one that writes code to verify a database.
    >
    > How else would these last 2 be done easily with a code generator?


    Misspoke, or you are you saying you don't see this day coming, either?

    Later... Karl
    --
    http://www.mvps.org/vb




  4. #64
    Mark Alexander Bertenshaw Guest

    Re: Correct Error Handling

    Karl -

    I disagree. Three years ago, I started HTML, as you suggested, using
    Notepad, and after reading a particularly good HTML tutor, I wrote
    beautifully indented HTML - IN CAPITALS; it looked lovely on the page. Then
    I started using Front Page, and days of effort was trashed in 5 minutes of
    "The Front Page Server Extensions are scanning the web site
    http://www.hikarma.com ". The bloody things had made everything lower case,
    and scrunched it all together! If I had just used Front Page from the start,
    I would have never known the pain. It's kinder this way.

    Maybe they'll add this "feature" in VB7. That way, they'll be loads of
    excuses for programmers not to code properly. <g>

    --

    ---------------------------------------
    Mark Alexander Bertenshaw
    Programmer/Analyst
    Prime Response
    Brentford
    UK
    "Karl E. Peterson" <karl@mvps.org> wrote in message
    news:392c48fd$1@news.devx.com...
    > Hi Liam --
    >
    > > Generators can
    > > also be used as great training tools for new developers.
    > >
    > > For example, in the case of web page creation, do you think that

    FrontPage
    > > is a useful tool? I do and so do a lot of other people that use it to

    generate
    > > HTML.

    >
    > Ack! You're not suggesting FP, or *any* code generator should be used by

    newbies,
    > are you? As a *training* tool??? Good grief. Yes, FP is incredibly

    useful, but
    > *only* if you already know HTML. No way, any dev worth the effort needs

    to spend a
    > year coding in Notepad before allowing software to code for him.
    >
    > > VB itself ships with a lot of useful wizards and templates that generate

    code
    > ^^^^^^
    > You misspelled "useless." HTH!
    >
    > Later... Karl
    >
    >




  5. #65
    Karl E. Peterson Guest

    Re: Correct Error Handling

    Hi Mark --

    > I disagree. Three years ago, I started HTML, as you suggested, using
    > Notepad, and after reading a particularly good HTML tutor, I wrote
    > beautifully indented HTML - IN CAPITALS; it looked lovely on the page. Then
    > I started using Front Page, and days of effort was trashed in 5 minutes of
    > "The Front Page Server Extensions are scanning the web site
    > http://www.hikarma.com ". The bloody things had made everything lower case,
    > and scrunched it all together! If I had just used Front Page from the start,
    > I would have never known the pain. It's kinder this way.


    Ouch. "I feel yo' pain!" Been there myself. The new FP2K doesn't screw with your
    formatting, though. I think MS got the message loud and clear.

    Anyway, I think your point sustains mine, rather than refutes it! <g>

    Later... Karl





  6. #66
    Mike Culley Guest

    Re: Correct Error Handling


    >LOL! I'd like to see that, but don't anticipate it anytime soon.


    Wasn't there one writted by VBPJ staff?

    >Not to mention InitProps, eh?


    Oops, forgot that one.

    >Misspoke, or you are you saying you don't see this day coming, either?


    Yep, this was a mistake. What I was trying to say was that if you wanted
    a function that created a database wouldn't this be a good candidate for
    a code builder? If you didn't use a code builder and didn't do it manually,
    how would you do it?

    Michael Culley




    "Karl E. Peterson" <karl@mvps.org> wrote:
    >Hi Mike --
    >
    >> Just like the VB property generator, but good.

    >
    >LOL! I'd like to see that, but don't anticipate it anytime soon.
    >
    >> When adding a property to
    >> a control, you have to put code in 5 places (variable

    >declare,Let,Get,ReadProp,WriteProp).
    >
    >Not to mention InitProps, eh?
    >
    >> Or how about a code generator that writes the code to create a database.
    >>
    >> Or one that writes code to verify a database.
    >>
    >> How else would these last 2 be done easily with a code generator?

    >
    >Misspoke, or you are you saying you don't see this day coming, either?
    >
    >Later... Karl
    >--
    >http://www.mvps.org/vb
    >
    >
    >



  7. #67
    Kathleen Dollard-Joeris Guest

    Re: Correct Error Handling

    Liam,

    I agree that Frontpage is better than hardcoding HTML. To me that is
    analogous to not having to instantiate windows for individual text boxes in
    VB.

    We disagree on code generators for VB though. The basic problem is that they
    result in too much code. Ones that have as much passion as a typist for
    reducing the number of lines (everything better have a darn good reason) are
    far better than those that don't. Everything in your program should be there
    for a darn good reason.

    A lot of the code that it does make sense for a generator to write in VB,
    comment blocks, error lines, etc, I strongly think should be handled by the
    language.

    --
    Kathleen
    (MS-MVP)
    Reply in the newsgroup so everyone can benefit
    --



  8. #68
    Mark Hurst Guest

    Re: Correct Error Handling


    There's another exception - callback functions invoked on late-bound objects
    behave as top-level functions (ie. untrapped errors in them are fatal).

    MarkH
    http://www.keysound.com/html/visual_basic.htm

    >BTW, technically, there is one exception to the rule that all unhandled

    errors
    >propagate up the call stack to an event procedure. That exception is when
    >you use Sub Main as your start up object. In this case, there is no top-level
    >event procedure.



  9. #69
    Mark Hurst Guest

    Re: Correct Error Handling


    An awful lot of effort has been expended (evident in this thread and elsewhere)
    to provide clever ways of obtaining stack traces when an unexpected error
    occurs, but VB can do this itself in the IDE! What I've never seen addressed
    is that in the field, unexpected errors should be few and far between and
    so probably don't warrant the amount of coding effort and bloat they are
    often afforded.

    Hey, it's just a point of view! For the same thing in more detail, see http://www.keysound.com/html/soapbox.htm.
    And if you're not convinced, see my own thoughts on how to do it properly
    at http://www.keysound.com/html/frameworks.htm.

    MarkH
    http://www.keysound.com/html/visual_basic.htm

    "Mike Culley" <m_culley@one.net.au> wrote:
    >
    >Hi All,
    >
    >It seam the standard method of handling unexpected errors is to put an on
    >error goto ErrorHandler at the start of each routine, log the error, etc.
    >
    >But my question is this. If you have a Function that gets called by another
    >function (anything that is not an event) then you don't _have_ to put error
    >handling in it - you can rely on the function calling it to trap the error.
    >What does everyone do in this situation.
    >
    >TIA
    >
    >Michael Culley



  10. #70
    Mark Hurst Guest

    Re: Correct Error Handling


    Oops, these URLs seem work better without the dots on the end:

    http://www.keysound.com/html/soapbox.htm

    http://www.keysound.com/html/frameworks.htm

    MarkH

  11. #71
    Jim Pragit Guest

    Re: Correct Error Handling


    Mark,
    It's an honor to meet you. I consider your "On Error Goto ****" to be the
    ultimate bible on error handling and often refer people to your website.
    However...
    I do tend to disagree with your dislike of error handling in most/all routines.
    I've found that knowing the routine where the error occurs can be helpful.
    Yes, it takes code, maybe too much code, but I would rather be safe than
    sorry. To me, the real problem lies in VB's error handling implementation.
    I've heard unconfirmed reports that VB7 will add centralized error handling
    and some sort callstack built-in. If these reports are true and if they
    make it into the final product, it will make all our lives much simpler.

    - Jim

    "Mark Hurst" <markh@keysound.com> wrote:
    >
    >An awful lot of effort has been expended (evident in this thread and elsewhere)
    >to provide clever ways of obtaining stack traces when an unexpected error
    >occurs, but VB can do this itself in the IDE! What I've never seen addressed
    >is that in the field, unexpected errors should be few and far between and
    >so probably don't warrant the amount of coding effort and bloat they are
    >often afforded.
    >
    >Hey, it's just a point of view! For the same thing in more detail, see http://www.keysound.com/html/soapbox.htm.
    >And if you're not convinced, see my own thoughts on how to do it properly
    >at http://www.keysound.com/html/frameworks.htm.
    >
    >MarkH
    >http://www.keysound.com/html/visual_basic.htm
    >
    >"Mike Culley" <m_culley@one.net.au> wrote:
    >>
    >>Hi All,
    >>
    >>It seam the standard method of handling unexpected errors is to put an

    on
    >>error goto ErrorHandler at the start of each routine, log the error, etc.
    >>
    >>But my question is this. If you have a Function that gets called by another
    >>function (anything that is not an event) then you don't _have_ to put error
    >>handling in it - you can rely on the function calling it to trap the error.
    >>What does everyone do in this situation.
    >>
    >>TIA
    >>
    >>Michael Culley

    >



  12. #72
    Richard Curzon Guest

    Re: Correct Error Handling

    We all have our foibles, one of mine is I'm still a mouse-hater... most of
    the time.

    I still think emacs is the best editor ever. I haven't used it for years
    now, but not a month passes where I don't miss it for something I could have
    done much easier. Fastest most powerful editor ever, and not a mouse in
    sight <grin>.

    Because no product manager ever got a say in it, never got a chance to chop
    something he didn't understand <grin>. Only reason I don't go back is
    because the GUI world finally came up with its own advantages: color syntax
    and intellisense!

    One reason I hated addins was they seemed all to brainlessly copy the MS
    sample. They all raised unnecessary forms and make you get off the
    keyboard, swear as you try to dig out the **** mouse wherever it got to,
    knock your coffee cup over, etc etc.

    If you share that foible you might want to base your addin in the
    "Office.CommandBarControl" object and get your code directly hooked to the
    IDE menus. When you're coding along and want an error trap, type "Alt-C E"
    and done, no form pops up, no mouse hunt. If you want a jump start I can
    send you a framework... FWIW <g>

    Richard.



  13. #73
    Mark Hurst Guest

    Re: Correct Error Handling


    Thanks for the kind comments. I spent years flying the 'overkill' error handling
    flag and it's only recently I realised that the things we're trying to capture
    just don't happen that often except during development - ie. the cool error
    handling stuff I ended up building never really got exercised in the field.
    Which is, of course, exactly why VB has a 'break on all errors' mode. This
    is a kind of eureka moment, and hence it's a hard one to try and convince
    other people of.

    As for VB7, I'm sure I read in the original VBITS stuff that it's got essentially
    the same error handling (and everything else) that Java and C++ have, so
    we'll certainly be able to write proper hierarchical exception handling.

    MarkH
    http://www.keysound.com/html/visual_basic.htm


  14. #74
    Anthony Jones Guest

    Re: Correct Error Handling

    Mark,

    >callback functions invoked on late-bound objects


    Could you explain the difference between the above and simply making a call
    to a late-bound object?


    --
    Anthony Jones
    Secta Group Ltd




  15. #75
    Anthony Jones Guest

    Re: Correct Error Handling

    Mark,

    I basically agree with your POV. When code is abstracted properly ala
    McConnell you end up with a lot of fairly short functions. Adding the
    overhead of an error handler in _all_ of these is, as you say, 'overkill'.

    However, Break On All Errors just doesn't cut it for me. The reason is
    (and you know what's coming) that I have error handlers to handle expected
    exceptions.

    I understand the point made on your site that exception handling is just
    that, to handle exceptions, and in the field unexpected exceptions should
    be rare hence loads of cool error handling code remains largely unused.

    Again there is a 'however', I believe you've missed a vital stage, that is
    Alpha, Beta versions and testing. It would be very unwise to leave testing
    done only in the IDE, in fact only developers should test in IDE. So when
    the test dept. has the very first alpha version we would want the maximum
    info reasonable from any errors raised. This is where the 'cool' error
    handling code really comes into it's own.

    So what does all this mean. Well for me it means that I'm putting more
    error handlers in than I find aesthetically pleasing but that is just tough
    cos they are a necessary evil. It's still not necessary to error handle
    every routine, very short and loosely coupled routines can often get away
    without one.

    Wanna see what 'cool' error handling code costs in additional lines to a
    procedure? ... Oh, ... well I'll show you any way.

    On Error Goto An_Error

    ....

    An_Error:
    If InDesign Then Stop: Resume
    Err.Push mcsModule & "<Procedure Name>", , True

    You probably recognize the If InDesign line. By placing expected exception
    handling before this line we can get the benefits of Break On All Errors
    with out the headaches.

    Err.Push is based on overloading the Error object with a custom built one
    that emulates and in most cases delegates to VBA.Err but adds additional
    methods such as Push. Push has the signature:

    Push(NewSource, NewDescription, ReRaise as Boolean) as Long

    It first places a copy of VBA.Err on a stack then if supplied the exisiting
    source and description are replaced. It optionally Re-Raises the error.

    One thing I particularly like about this approach is that the normal
    program flow is largely unaffected by the error handling code. This means
    it can be left in place for a production build since there is little
    benefit derived from removing it.

    The conclusion is that 'cool' error handling is often necessary but should
    not be applied in a blanket or blind fashion and with an appropriate
    framework doesn't have to be too burdensome.

    --
    Anthony Jones
    Secta Group Ltd




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center