Error handling in property procedures

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • WSeeger

    Error handling in property procedures

    When creating a new class, is it encouraged to always include error
    handling routines within your LET and GET procedures? It's seems that
    most text books never seem to include much about error handling within
    classes. Just hoping to hear some programmer's thoughts on error
    handling.
  • Stephane Richard

    #2
    Re: Error handling in property procedures

    Well I'm all for it, however I wouldn't have the class display a message or
    anything...

    Say you have a form and a support cls module. In the class module you could
    have error management, but instead of managing the error, I would just have
    the class raise an error and manage the error (show message or log the
    error) at the form level instead of it's class.

    --
    Stéphane Richard


    "WSeeger" <wseeger1@yahoo .com> wrote in message
    news:b937312c.0 310141800.23727 28b@posting.goo gle.com...[color=blue]
    > When creating a new class, is it encouraged to always include error
    > handling routines within your LET and GET procedures? It's seems that
    > most text books never seem to include much about error handling within
    > classes. Just hoping to hear some programmer's thoughts on error
    > handling.[/color]


    Comment

    • Steve Gerrard

      #3
      Re: Error handling in property procedures


      "WSeeger" <wseeger1@yahoo .com> wrote in message
      news:b937312c.0 310141800.23727 28b@posting.goo gle.com...[color=blue]
      > When creating a new class, is it encouraged to always include error
      > handling routines within your LET and GET procedures? It's seems that
      > most text books never seem to include much about error handling within
      > classes. Just hoping to hear some programmer's thoughts on error
      > handling.[/color]

      Okay, here are some thoughts on error handling:

      All programs should have a good, well organized, error handling scheme. It
      should guarantee that no user will ever see a "VB Runtime Error" and get shut
      down; that if something goes wrong, as much of the data as possible is saved;
      and that the user gets some hint as to what they should do next when an error
      occurs.

      Always including error handlers in every procedure is not a good or well
      organized error handling scheme. Try to identify the appropriate level at which
      errors should be trapped. It might be the initial user event, the routine it
      calls, the nested routine it calls in turn, or an object let procedure. Do you
      need to slam on the brakes, or just make a note of it?

      Error handlers slow down program execution. A simple Let/Get pair, if they are
      typed (not Variant), may not do anything that can cause an error - invalid
      assignments wil be an error in the calling procedure. So no, it is not
      encouraged to always put error handlers in Let/Get procedures, especially if the
      objects are used inside loops millions of times.

      It is sad that "most text books never seem to include much about error
      handling". It is well worth spending the time to get it right, if the program is
      going to be used much.


      Comment

      Working...