FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » out of sheer curiosity...
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: out of sheer curiosity... [message #177616 is a reply to message #177597] Tue, 10 April 2012 21:28 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 4/10/2012 12:33 PM, Leonardo Azpurua wrote:
> "Jerry Stuckle"<jstucklex(at)attglobal(dot)net> escribió en el mensaje
> news:jm1mku$hqm$3(at)dont-email(dot)me...
>>
>> If you want to call __wakeup() a constructor, then you need to call
>> __sleep() a destructor. You can't have it both ways.
>
> Hi,
>
> That would be if I had an obssesive love for symmetry, which is not the case
> :-)
>
> I don't care much about terms.
>
> PHP lacks polymorphic constructors (a limitation which, after several years
> using the best available OO practices with VB6, I can perfectly cope with).
> So, if you need an alternate way to fill an object's data members, then
> __wakeup seems to come in very handy.
>
> With __construct(<args>), you initialize -i.e. fill data members and create
> the appropriate internal states- the object from args.
>
> With __wakeup you know you have your top level data members initialized
> (from a previous state), so you have to rebuild the apropriate internal
> states.
>
> I have no problem at all with that. It may not be symmetric (but, again, who
> cares?), but it is precisely documented and it works as expected (I guess,
> since I have had no experience at all with PHP serialization).
>
> --
>
>

Because it's a violation of OO concepts? It's caused me problems more
than once. I no longer even try to store objects in the session. It's
hopeless.

For instance - what if one of the things your object needs is a database
connection? And what if you have several objects using that same
connection? There is no way to pass an existing database connection to
__wakeup(). You either have to use a global variable, restricting
variable names in the rest of your code and limiting flexibility, or
create a new connection in the __wakeup() call or remember to call
another method to set the database connection after unserializing the
object.

None are good answers - but all could be easily handled with proper use
of constructors.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 5.4 windows installer.
Next Topic: Does PHP5 treat $_SERVER['PHP_AUTH_USER']) differently?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 14:00:16 GMT 2024

Total time taken to generate the page: 0.04877 seconds