By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,389 Members | 2,065 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,389 IT Pros & Developers. It's quick & easy.

Error handling in property procedures

P: n/a
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.
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <ws******@yahoo.com> wrote in message
news:b9**************************@posting.google.c om...
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.

Jul 17 '05 #2

P: n/a

"WSeeger" <ws******@yahoo.com> wrote in message
news:b9**************************@posting.google.c om...
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.


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.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.