On Sat, Aug 31, 2002 at 02:03:47AM +0900, R. Lahaye wrote:
> Are you saying I should do something like:
> 
> frnt::OriginType GUI_conversion(int const GUI_choiceItem)
> {
>       switch (GUI_choiceItem) {
>               case 11: return(frnt::RightBaseline);
>               case 10: return(frnt::RightBottom);
>               [...]
>               case  2: return(frnt::LeftTop);
>               case  1:
>               default:  return(frnt::DefaultOrigin);
>       }
> } 

What's wrong with that? [Apart from the superflous () in return and the 
strange name?] The conversion has a purpose. Name that purpose and call the
function like that.

> And then later in the script I call ONCE the first conversion (apply part):
>       igp.origin = GUI_conversion(fl_get_choice(extra_->choice_origin));

Even if functions are called only once they might help in splitting a long
sequence into logical chunks. Of course there is no sense in doing that for
one-liners, but 15 lines look ok to me.

> However, I can't see any advantage of having the trouble of making a
> function, but calling it only once!

You do one thing (conversion) in one line in the "main" function. And if
the function has a suitable name there is not even a need to look up that
function when reading the code.

> Are you still in favour of using
> such help functions in this context?

Yes. A bit at least. But as I am off for ten days now you got to fight with
other peoples now anyway ;-)

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)

Reply via email to