Re: More than one values returned?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 18, 2008 at 9:06 PM, Nick Stinemates <nick@xxxxxxxxxxxxxx>
wrote:

> Thats a good example, and a good reason for passing values by Reference
> instead of by Value.
>
> I have found, however, that if I ever need to return /multiple/ values,
> it's usually because of bad design and/or the lack of proper
> encapsulation.


and this is what i was responding to earlier, nick, although you didnt
criticize
pass-by-reference directly you essentially said use of it indicates bad
design,
which i disagree with.
check my post where i show a method with a boolean return value that has a
pass-by-reference parameter to return data; that is a perfectly reasonable
use
case for pass-by-reference and it does not indicate bad design.  nor would
it, if
there were more pass-by-reference parameters in that method.

and here is another reason you might have to return more than on value from
a
method; a function needs to return data of different types.  now php is
loosely
typed, so packaging these into an array is a joke, but in other languages,
that
are strongly typed, its not quite that simple.  any way, when i think about
a method
returning  a class, what if for whatever reason, a method were to return
objects of
2 classes ?  do you then create another class just for the purpose of
packaging those
2 objects for this method to return a single value?
well ill let you be the judge of that, but i would probly toss them in a
small array, or,
depending on the scenario, use pass-by-reference, especially if i wanted to
return
a boolean value from the method ;)

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux