RE: [code-review] Re: Lingua::Phonology

"Hodges, Paul" <[email protected]> Thu, 13 Nov 2003 08:24:22 -0600
Newsgroups gmane.comp.lang.perl.code-review-ladder
Message-ID <9C375DDD9B669243A2D78FCD607E894003E4FCF2@bremo-jg>
> > sub new {
> >     my $proto =3D shift;
> >     my $class =3D ref($proto) || $proto;
> >     my $self  =3D bless {}, $class;
> >
> >     $self->{FEATURES} =3D new Lingua::Phonology::Features;
> >     $self->{SYMBOLS}  =3D =
Lingua::Phonology::Symbols->new($self->{FEATURES}); # ??
> >     $self->{RULES}    =3D new Lingua::Phonology::Rules;
> >     $self->{SYLL}     =3D new Lingua::Phonology::Syllable;
> >
> >     return $self;
> > }
> >
> > In general, I try to avoid the 'indirect object' syntax for methods.
>=20
> Duly noted. I only use it for "new" calls, just because "new Class" is
> such a common statement and is common across other languages.

Personally, I'm more surprised that you changed the syntax when you had =
an argument.
Couldn't
     $self->{SYMBOLS}  =3D =
Lingua::Phonology::Symbols->new($self->{FEATURES});=20

have as easily been
     $self->{SYMBOLS}  =3D new Lingua::Phonology::Symbols =
$self->{FEATURES};=20
??

Yes, $self->{FEATURES} makes it read a little funny, and personally I =
prefer the indirect syntax merely for the poetic flow, but why change =
and then change back?=20

Yes, I know it's irrelevant, but I ask your indulgence. I just think =
it's important to be consistent. (Which is why I neurotically lined up =
the =3D's in the example, so you have to consider the source, lol...)

As a more serious question, why "try to avoid the 'indirect object' =
syntax for methods"?
I think it's a lot less line-noisy sometimes. Somebody tell me why/how =
I'm being stupid?

> Anyway, having not done it right the first time, I now have=20
> the problems that you see here.

Sounds like time to refactor. I'd deprecate the old methods, and =
refactor them to allow the same old use to achieve the same old result =
using a less efficient subcall to the more efficient and more consistent =
single newer method...but then, *I'm* not going to, so I understand why =
you might not, either. Your module, your call.


*****
"The information transmitted is intended only for the person or entity =
to which it is addressed and may contain confidential, proprietary, =
and/or privileged material.  Any review, retransmission, dissemination =
or other use of, or taking of any action in reliance upon, this =
information by persons or entities other than the intended recipient is =
prohibited.  If you received this in error, please contact the sender =
and delete the material from all computers." 117