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 #177540 is a reply to message #177539] Sun, 08 April 2012 21:15 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 4/8/2012 4:50 PM, M. Strobel wrote:
> Am 29.03.2012 22:11, schrieb Jerry Stuckle:
>> On 3/29/2012 10:21 AM, Erwin Moller wrote:
>>> On 3/29/2012 3:39 PM, Jerry Stuckle wrote:
>>>> On 3/29/2012 8:33 AM, Erwin Moller wrote:
>>>> > On 3/29/2012 12:46 PM, The Natural Philosopher wrote:
>>>
>>> <snip>
>>>
>>>> >> Its just another way of doing things and I let my understanding of the
>>>> >> problem guide me, not a set of arbitrary rules.
>>>> >
>>>> > As it should!
>>>> >
>>>> > But what 'rules' are you referring to?
>>>> >
>>>> > PHP's OO is pretty straightforward.
>>>> > I think they did a decent job implementing OO.(php 5 that is)
>>>> >
>>>> > Creating smart classes is up to the programmer.
>>>> > I am not aware of any extra 'rules'.
>>>> >
>>>> > Are you maybe referring to all kinds of design patterns scattered around
>>>> > the web?
>>>> > (In which case I tend to agree, because implementing other people's
>>>> > solutions can take the fun out of programming. But reading them never
>>>> > hurts. And when you agree to a certain approach you can even decide to
>>>> > follow it yourself. It is all up to you, the programmer.)
>>>> >
>>>>
>>>> Any rules TNP doesn't bother to understand are "arbitrary" in his mind.
>>>> He doesn't even like having to follow PHP syntax rules - as he has also
>>>> said in the past.
>>>>
>>>> But I disagree that PHP 5's implementation of OO is decent. I think it's
>>>> half-assed at best. Truly written by people who have no understanding of
>>>> OO. But then that can be said of a lot of PHP.
>>>>
>>>
>>> Jerry,
>>>
>>> What are your main objections to the PHP5's OO approach?
>>>
>>> For myself: I must say I love its simplicity.
>>> (Simplicity is a Good Thing in my opinion.)
>>>
>>>
>>
>> Well, to start with, the lack of function overloading. It is quite a good feature to
>> be able to overload functions - especially constructors. And because of that, you
>> have to run through all kinds of hoops when doing things like storing an object in
>> the $_SESSION.
>>
>> Even then it doesn't work. When you store an object in the $_SESSION, the object's
>> destructor is called at the end of the script, but on the next script the constructor
>> is never called. A direct violation of OO principles.
>
> Works fine here. Test script:
> #!/usr/local/bin/php
> <?php
>
> class C1 {
> public $var1 = 'M.';
> public $var2 = 'Strobel';
> function __construct() {
> echo "\t--> call ". __METHOD__.PHP_EOL;
> }
> function __destruct() {
> echo "\t--> call ". __METHOD__.PHP_EOL;
> }
> function __sleep() {
> echo "\t--> call ". __METHOD__.PHP_EOL;
> return array('var1','var2');
> }
> function __wakeup() {
> echo "\t--> call ". __METHOD__.PHP_EOL;
> }
> } // end class C1
>
> echo "----- creating class\n";
> $c = new C1;
> echo "----- serializing class\n";
> $ser = serialize($c);
> echo "----- deserializing class\n";
> $cc = unserialize($ser);
> echo "----- deleting first class\n";
> unset($c);
> echo "----- deleting unserialized class\n";
> unset($cc);
> exit(0);
> #-----------------------
>
> Result:
> strobel@s114-intel:~/projekte/PHP> ./magicmethods.php
> ----- creating class
> --> call C1::__construct
> ----- serializing class
> --> call C1::__sleep
> ----- deserializing class
> --> call C1::__wakeup
> ----- deleting first class
> --> call C1::__destruct
> ----- deleting unserialized class
> --> call C1::__destruct
>
> What exactly did you criticize?
>
> /Str.

Look at it again. You have two destructor calls but only one
constructor call. A direct violation of OO principles.

And BTW - I said nothing about serializing.

You really do need to learn to read.

--
==================
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:38:19 GMT 2024

Total time taken to generate the page: 0.05490 seconds