[MTOS-dev] More sophisticated interface of MT::Template::Node
Hirotaka Ogawa
hirotaka.ogawa at gmail.com
Sat Mar 1 17:36:48 PST 2008
On Sun, Mar 2, 2008 at 5:12 AM, Jay Allen <jay at endevver.com> wrote:
> 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});
No problem. I thought that MT::Template::Node used an array just for
space and time efficiency, so I left it as it be.
--
Hirotaka Ogawa makes no sense.
http://as-is.net/blog/
More information about the MTOS-dev
mailing list