Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return Multiple Values From a UDF
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
00979276
Message ID:
00979564
Views:
12
George:

RE: Functional Cohesion

Yes, indeed, a given method/procedure/function should do one, and only one, thing. That may not be the same as returning exactly one result, however.

I'm doing some work that involves linear regression, which determines the "best" line to fit through a series of data points. A line is given by the formula
Y = A + B * X
so the definition of this line actually requires two values (A and B), and invoking a routine to perform linear regression should indeed return both values.

Cheers,

Jim



>>To All:
>>IS there a way in VFP to return multiple values from a User Defined Function? I don't want to use an Array, then I have to pass by reference and I am trying to avoid that. I have thought about casting and concatenating the values to a single string then returning that and parsing it when needed but I know there has to be a 'cleaner' way to accomplish this.
>>
>>Thanks!
>
>Woodie,
>
>As the others have told you, there're a number of ways of doing this. What they haven't told you is that this isn't a particularly good idea.
>
>Why? Good practice is to invoke functional cohesion. What this means is that a given method/procedure/function does one, and only one, thing only.
>
>This makes your code more flexiable, and, at the same time, more re-usable.
Jim Nelson
Newbury Park, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform