Re: General Question On Handling of Function results.t

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
>>>
>>
>>
>
>


.



Relevant Pages

  • Re: General Question On Handling of Function results.
    ... Best Regards ... i create a structure with the required info and ... > use exception handling if you do not see anny other way, ... but a simple boolean is not enough. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: General Question On Handling of Function results.t
    ... I will addopt this principle from now onwards. ... Best Regards ... > might confuse another programmer working new on the project, ... >>> use exception handling if you do not see anny other way, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Delphi type events in C#
    ... Beste Grüsse / Best regards / Votre bien devoue ... procedure TMyNewEvent (Sender: TObject; MyStream: TStream; var MyFlag: boolean) Of Object; ... procedure DoMyEvent(Sender: TObject; AStream: TStream; var AFlag: boolean); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: "with" Coders are Monsters
    ... class function TfrmSomeForm.ClassExecute: Boolean; ... Regards, ... that chaps my butt more than anything. ...
    (borland.public.delphi.non-technical)
  • Re: SUMPRODUCT is making me mad!
    ... The double negation is not needed here since the addition operator coerces ... Boolean to numeric ... > Frank Kabel ...
    (microsoft.public.excel.worksheet.functions)