object in a function!?

This is a discussion on object in a function!? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I have one little issue here.... let say that I have a function , and in that function some object functions ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-14-2003
point
 
Posts: n/a
Default object in a function!?

I have one little issue here....

let say that I have a function ,

and in that function some object functions are used....

which is better

a) function something($,var1,$var2,$var3,&$object)
{
//and then keep using object functions
}

or

b)function something($,var1,$var2,$var3)
{
$object = & NEW someClass;
//and then keep using object functions
}

I used the first solution but want to hear some more oppinions.....

respect...
point


Reply With Quote
  #2 (permalink)  
Old 07-14-2003
^MisterJingo^
 
Posts: n/a
Default Re: object in a function!?

"point" <info@caanproduction.com> wrote in message
news:beuo13014jt@enews2.newsguy.com
> I have one little issue here....
>
> let say that I have a function ,
>
> and in that function some object functions are used....
>
> which is better
>
> a) function something($,var1,$var2,$var3,&$object)
> {
> //and then keep using object functions
> }
>
> or
>
> b)function something($,var1,$var2,$var3)
> {
> $object = & NEW someClass;
> //and then keep using object functions
> }
>
> I used the first solution but want to hear some more oppinions.....
>
> respect...
> point


Well the second solution scopes the object to the function, if the object is
needed outside of it (which I guess it is) then number two isn't really
feasible. Passing the object by reference, which you have done, is sensible
(on the information you have given us.)


Reply With Quote
  #3 (permalink)  
Old 07-14-2003
^MisterJingo^
 
Posts: n/a
Default Re: object in a function!?

"^MisterJingo^" <misterjingo@keysurf.net> wrote in message
news:_3CQa.70$B91.17@news-binary.blueyonder.co.uk
> "point" <info@caanproduction.com> wrote in message
> news:beuo13014jt@enews2.newsguy.com
>> I have one little issue here....
>>
>> let say that I have a function ,
>>
>> and in that function some object functions are used....
>>
>> which is better
>>
>> a) function something($,var1,$var2,$var3,&$object)
>> {
>> //and then keep using object functions
>> }
>>
>> or
>>
>> b)function something($,var1,$var2,$var3)
>> {
>> $object = & NEW someClass;
>> //and then keep using object functions
>> }
>>
>> I used the first solution but want to hear some more oppinions.....
>>
>> respect...
>> point

>
> Well the second solution scopes the object to the function, if the
> object is needed outside of it (which I guess it is) then number two
> isn't really feasible. Passing the object by reference, which you
> have done, is sensible (on the information you have given us.)


Although if the function is used to just change members stored in the
object, the possibility exits to make it a method of the object.


Reply With Quote
  #4 (permalink)  
Old 07-14-2003
point
 
Posts: n/a
Default Re: object in a function!?

Yeah I also think the first one becuse those $var's that I also pass have
nothing to do with object....

The function is not used to change any members of object just uses some
functions that belong to the object itselfe....

Object is also used on the page where the function so the first one seems
reasonable....

Thanx for your oppinion...

Respect....
"^MisterJingo^" <misterjingo@keysurf.net> wrote in message
news:A5CQa.86$B91.77@news-binary.blueyonder.co.uk...
> "^MisterJingo^" <misterjingo@keysurf.net> wrote in message
> news:_3CQa.70$B91.17@news-binary.blueyonder.co.uk
> > "point" <info@caanproduction.com> wrote in message
> > news:beuo13014jt@enews2.newsguy.com
> >> I have one little issue here....
> >>
> >> let say that I have a function ,
> >>
> >> and in that function some object functions are used....
> >>
> >> which is better
> >>
> >> a) function something($,var1,$var2,$var3,&$object)
> >> {
> >> //and then keep using object functions
> >> }
> >>
> >> or
> >>
> >> b)function something($,var1,$var2,$var3)
> >> {
> >> $object = & NEW someClass;
> >> //and then keep using object functions
> >> }
> >>
> >> I used the first solution but want to hear some more oppinions.....
> >>
> >> respect...
> >> point

> >
> > Well the second solution scopes the object to the function, if the
> > object is needed outside of it (which I guess it is) then number two
> > isn't really feasible. Passing the object by reference, which you
> > have done, is sensible (on the information you have given us.)

>
> Although if the function is used to just change members stored in the
> object, the possibility exits to make it a method of the object.
>
>



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:44 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0