Zend_Object Proposal

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend_Object Proposal

Ondrej Ivanič
Hi

Zend_Object is a basic implementation of dynamic properties in objects.
If yours object need access like this:

$config->menu->color = 'red';

You only need extends this object.

http://www.zlty-pes.sk/zend/ZObject-proposal.txt
http://www.zlty-pes.sk/zend/ZObject.phps

--
Ondrej Ivanic
([hidden email])
Reply | Threaded
Open this post in threaded view
|

答复: [fw-general] Zend_Object Proposal

etng
Hello,I want to Know the parameter $depth  for the method setReadOnly.
It puzzles me.
Thank you!

-----邮件原件-----
发件人: Ondrej Ivanič [mailto:[hidden email]]
发送时间: 2006年5月24日 5:46
收件人: [hidden email]
主题: [fw-general] Zend_Object Proposal

Hi

Zend_Object is a basic implementation of dynamic properties in objects.
If yours object need access like this:

$config->menu->color = 'red';

You only need extends this object.

http://www.zlty-pes.sk/zend/ZObject-proposal.txt
http://www.zlty-pes.sk/zend/ZObject.phps

--
Ondrej Ivanic
([hidden email])

Reply | Threaded
Open this post in threaded view
|

Re: Zend_Object Proposal

Art Hundiak
In reply to this post by Ondrej Ivanič
I would vote no on this.  When a class extends another class it should
imply that the child object IS A parent object with some modifications.
Trying to add methods common to all classes to a base class seldom works
out well in practice.

Maybe an interface but even that is really not needed for such basic
functionality.

If you want a few more opinions on this try reading through this thread:
http://www.sitepoint.com/forums/showthread.php?t=298611

After about 20 posts the folks settle down and try to figure out the best
interface for this sort of functionality.  200 or so posts later they end
up no where.

>
> Hi
>
> Zend_Object is a basic implementation of dynamic properties in objects.
> If yours object need access like this:
>
> $config->menu->color = 'red';
>
> You only need extends this object.
>
> http://www.zlty-pes.sk/zend/ZObject-proposal.txt
> http://www.zlty-pes.sk/zend/ZObject.phps
>
> --
> Ondrej Ivanic
> ([hidden email])
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Zend_Object Proposal

Ondrej Ivanič
Art Hundiak wrote:
> I would vote no on this.  When a class extends another class it should
> imply that the child object IS A parent object with some modifications.
> Trying to add methods common to all classes to a base class seldom works
> out well in practice.

Yes, you are right. This class isn't to be a parent class for all
classes in a framework. Many frameworks have a common class for
specifics objects types (java.lang.Object, ...)

>
> Maybe an interface but even that is really not needed for such basic
> functionality.

If you have an interface you need it implements every time. This class
can prevent copy&paste programing and create clean, useful and robust
implementation.

Zend_Object isn't a good name, but i don't have better :)

--
Ondrej Ivanic
([hidden email])

Reply | Threaded
Open this post in threaded view
|

Re: 答复: [fw-general] Zend_Object Proposal

Ondrej Ivanič
In reply to this post by etng
etng wrote:
> Hello,I want to Know the parameter $depth  for the method setReadOnly.
> It puzzles me.
> Thank you!

If is true, setReadOnly is called for every nested properties which are
extends Zend_Object.

function setReadOnly($depth = false) {
        $this->readonly = true;

        if($depth) {
                foreach($this-data as $obj) {
                        if($obj instanceof self) {
                                $obj->setReadOnly($depth);
                        }
                }
        }
}


--
Ondrej Ivanic
([hidden email])