Re: General Question On Handling of Function results.t
- From: "m.posseth" <michelp@xxxxxxxxxxxxxxx>
- Date: Sun, 27 Nov 2005 16:29:42 +0100
personally i do not have anything against option 3 however i feel option 4
is more straightforward in what is happening ( the code explains itself )
while using a byref value to create an extra return value
might confuse another programmer working new on the project , and as we are
now all working with objects why not a return object ?
regards
Michel Posseth [MCP]
"Mr Newbie" <here@xxxxxxx> wrote in message
news:eIK4syz8FHA.2192@xxxxxxxxxxxxxxxxxxxxxxx
> 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: Mr Newbie
- 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
- Re: General Question On Handling of Function results.
- From: Mr Newbie
- General Question On Handling of Function results.
- Prev by Date: Capture http post request
- Next by Date: combobox selectedindexchanged doesn't raise
- 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
|