[Koha-patches] [PATCH] REFACTOR: correcting indirect object method syntax

Andrew Moore andrew.moore at liblime.com
Thu Dec 18 18:04:33 CET 2008


On Thu, Dec 18, 2008 at 10:56 AM, Jesse Weaver <jesse.weaver at liblime.com> wrote:
>
> I know that some newer parts of Koha use "CGI->new", and most of it uses
> "new CGI".
>
> ->new() seems to be a bit more kosher, but this is a very rough guess. Is
> this something we should add to the coding guidelines on the wiki?

Oh, I guess I incorrectly thought it was already part of the coding
guidelines. I personally think it should be, but I'm not sure what
process to go through to get it on there.

Here's my argument for it, borrowing heavily from Perl Best Practices:

The indirect syntax: <my $q = new CGI;> will work fine for a while.
Then, if someone creates a function named "new" in that package, or
another package exports a function called "new", then that call can
parse differently and call that "new" function instead of the on in
the CGI package. That's rather unexpected "action at a distance" and
is a hard bug to track down.

I'm pretty sure that's why indirect object syntax is frowned upon in
such large amounts of perl.

So, how do we make this an official policy?

-Andy



More information about the Koha-patches mailing list