[EMAIL PROTECTED] wrote:
> Hello
> 
> Just out of curiosity why do you need such a function? I'm no
> perl programmer and have very little knowledge of the
> language ... yet ; ) but the way you describe it it seems to
> me that you have  a fundamentle design flaw in your script if
> you need to change types on the fly that are in no way
> related to each other. (Even in a typeless language such as PHP)
> 
> My suggestion:
> For the cases you need the blessing create a proxy object or
> an adapter object to give you access to the needed stuff.
> 
> Regards
> Stefan Langer

There might be a design flaw in the scripts. Though what you mention is not
entirely true. I don't want to change the type of my object to change it to
another that is not related. They are related, very much. I'm changing an
instance of a 'superclass' to one of it's 'subclasses'. Here's the picture a
little more in detail, though still global:

        - Two classes, SuperClass and SubClass
        - One Table in the database
        - This table holds some columns, one of them being "instance_of"
        - my class SuperClass has a method ->New($ID); which loads the row
from
        the database representing the wanted object. At this point I do not
know
        what the object should be an instance of.
        - As soon as the Object finds out it's in instance of SubClass I
want
        it to become an instance of this SubClass, because there's some
overloaded
        methods that are to be called upon loading and stuff. And of course
some
        others to be run at other points in the script ;)

Any design related remarks are just as welcome as suggestion on how to bless
the object.

Wouter

[Example Snipplet]
class SuperClass {
        (.. attributes ..)
        function SuperClass($ID = false) {
                if ($ID) $this->Load($ID);
        }

        function Load($ID) {
                $Row = mysql_select('SELECT * FROM table WHERE id =
'.$ID.'')
                ( .. Hey, now I see it should become SubClass
                how can I become that .. )
                $this->DoSomething($Row);
        }

        function DoSomething($dbRow) {
                ( .. processing some things .. )
        }
}

class SubClass {
        ( .. attributes .. )
        funtion SubClass() {

        }

        function DoSomething($dbRow) {
                ( .. also some processing, but a little different .. )
        }
}
[/Example Snipplet]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to