Re: General Question On Handling of Function results.
- From: "Mr Newbie" <here@xxxxxxx>
- Date: Sun, 27 Nov 2005 10:24:09 -0000
Thanks for your reply. Option 4 is of course the purist way to do this and
sits nicley with what we think about functions, put things in the arguments
return something back. Just out of curiosity, do you have an objection to
option 3, and if so what would it be ?
--
Best Regards
The Inimitable Mr Newbie º¿º
"m.posseth" <michelp@xxxxxxxxxxxxxxx> wrote in message
news:%23P9Zy4s8FHA.4008@xxxxxxxxxxxxxxxxxxxxxxx
>I normally use option 4 , i create a structure with the required info and
>return this if i need to return multiple values
>
> use exception handling if you do not see anny other way, it is much
> faster if you can evaluate a value and return this to take apropriate
> action as to use a try catch statement or throwing errorr
>
> regards
>
> Michel Posseth [MCP]
>
> "Mr Newbie" <here@xxxxxxx> wrote in message
> news:%23FdSMfq8FHA.2036@xxxxxxxxxxxxxxxxxxxxxxx
>>I am often in the situation where I want to act on the result of a
>>function, but a simple boolean is not enough. For example, I may have a
>>function called
>>
>> isAuthorised ( User, Action ) as ?????
>>
>> OK, this function may return a boolean, and if this is true, then no
>> message back is really required, but if it fails then some supporting
>> message needs to be returned to the calling code. As I see it there are a
>> few options.
>>
>> 1.) Throw an exception with the message in ( But this tends to slow down
>> execution a little ?? )
>>
>> 2.) Return an enumeration type, but this is a little cumbersome because
>> it means I have to define all my possible return combinations against a
>> number, which could become messy.
>>
>> 3.) Add a third parameter called message which can be set to any error
>> message returned.
>>
>> 4.) Return a structure which contains a boolean and a string describing
>> the result.
>>
>>
>> Can I ask what you guys normally do in this situation, what is best
>> practice, pros and cons etc.
>>
>>
>> Thanks
>>
>> Mr N
>>
>
>
.
- Follow-Ups:
- Re: General Question On Handling of Function results.t
- From: m.posseth
- Re: General Question On Handling of Function results.t
- References:
- General Question On Handling of Function results.
- From: Mr Newbie
- Re: General Question On Handling of Function results.
- From: m.posseth
- General Question On Handling of Function results.
- Prev by Date: Re: Why Doesn't 13 Equals 13?
- Next by Date: Re: Declaritive security attribute help!
- Previous by thread: Re: General Question On Handling of Function results.
- Next by thread: Re: General Question On Handling of Function results.t
- Index(es):
Relevant Pages
|