nospam@nospam.nospam (Steve Jorgensen) wrote in
<j9keqvo0714mpnrmndfm7e3sfmimo5cl4f@4ax.com>:
[color=blue]
>On Mon, 03 Nov 2003 20:26:03 GMT,
dXXXfenton@bway.net.invalid
>(David W. Fenton) wrote:
>[color=green]
>>rkc@yabba.dabba.do.rochester.rr.bomb (rkc) wrote in
>><3dxpb.45015$ZC4.44052@twister.nyroc.rr.com>:
>>[color=darkred]
>>>Once again, there only needs to be one class. One class that
>>>contains all the error numbers and descriptions. One class that
>>>exposes the error numbers as property get routines. One class
>>>that raises the correct error through a public method that takes
>>>one of the error numbers defined by itself as a parameter.[/color]
>>
>>Steve's gone in a very different direction than what I foresaw.
>>
>>He's using a table to store his error definitions, as I
>>suggested, and his reason is to make it possible to keep multiple
>>attributes of a single error correlated.
>>
>>I had suggested that once you do this, you really need only two
>>things:
>>
>>1. a module with the constants for your error numbers (generated
>>in code).
>>
>>2. a module or class with the functions necessary to raise the
>>error.
>>
>>You'd pass the class the error constant and the class would then
>>raise the error with the appropriate error description and do
>>whatever else you wanted it to do. The class itself could have as
>>many methods and properties as you wanted, but I would make them
>>all generic, rather than generating a class with properties
>>specific to all your errors.
>>
>>Steve's objection to the table was that you couldn't enforce it
>>with compiling. His solution to that was to autogenerate the
>>constants. My thought is that all you really need are the
>>constants for the error numbers themselves (which are actually
>>the PK of your table) as your way of getting to all the other
>>attributes of your errror. And your class or module for raising
>>your error and examining its attributes would simply be a lookup
>>of a particular error code in the error table.
>>
>>With this solution you get:
>>
>>1. simple, generic code.
>>
>>2. as many custom attributes of your errors as you need.
>>
>>3. with the auto-generated module of error number constants, you
>>get compile-time enforcement of error codes without needing to
>>worry about correlating a set of multiple error attributes for
>>each error, since the error number is itself a pathway into the
>>lookup for all the other attributes.
>>
>>You'd only need one instance of your error class (if you went
>>that route), since you can only raise one error at a time.[/color]
>
>My thinking was that if I'm generating the code anyway, why not
>take this a step farther than simply generating a list of
>constants and a way to look up the other information about the
>constants. Why not generate named functions that directly return
>class instances that encapsulate all the properties and methods of
>the errors.[/color]
As long as a human being is going to be progamming in the database,
seems to me you want the amount of generated code to be as small
as possible.
[color=blue]
>To raise a "DontDoThat" error, just say XyzErrDontDoThat().Raise.
>You don't have to think in terms of looking things up at all, just
>tell the error to raise itself. Would you agree or disagree this
>is an improvement over generating constants and passing them to
>one or more lookup functions.[/color]
No, because it proliferates a huge amount of duplicative code.
--
David W. Fenton
http://www.bway.net/~dfenton
dfenton at bway dot net
http://www.bway.net/~dfassoc