[MTOS-dev] More sophisticated interface of MT::Template::Node
Jay Allen
jay at endevver.com
Sat Mar 1 12:12:36 PST 2008
On Sat, Mar 1, 2008 at 11:11 AM, Hirotaka Ogawa
<hirotaka.ogawa at gmail.com> wrote:
>
> Because MT::Template::Node has neither a constructor nor sufficient
> accessors, we need to specify which references are weak, at every
> constructions of NODE object and every updates of weak-referenced
> fields of NODE. It is also not good, as for readability and
> maintainability. Who knows $node->[2]->[0]->[2]->[0] means the first
> child of the first child of $node?
Hi Ogawa-san,
I haven't tested your patch, but I read over it briefly. I think this
is a fantastic change for a number of reasons but outside of the
obvious one related to proper OO and weak references, the most
striking one is that it's INFINITELY MORE READABLE.
Without any documentation, Su and I were trying to read the code with
all of those array references to try to figure out how the data
flowed. Your patch dispenses with the need for most of these which is
great.
If there's anything that I would like to see changed it would be to
stop using an array and start using a hash reference for arguments.
That is, instead of:
return NODE->new('TEXT', undef, undef, $text, undef, undef, $tmpl);
we do:
return NODE->new({type => 'TEXT', blah => $text, tmpl => $tmpl});
Jay
More information about the MTOS-dev
mailing list