Sorry, Chris, but I'm not sure I understand what you're saying here. I suppose I don't really think about it in terms of libraries but rather in terms of classes. In theory, a script should be able to be broken down into concepts which fit into classes. I think sometimes we end up using subroutines in scripts because we haven't scrutinized the actual "function" enough. For instance, take a look at tools/letter.pl. Another scary one is opac/oai.pl, although that's actually created packages in the pl script which I think is actually worse in a way. Maybe it's not feasible to always have subroutines defined in Perl Modules. However, I rather there be a blanket ban on them, and allow exceptions to that rule on the discretion of the QA team and the RM. As Tomas has said, I think there's been an existing practice for some at least a few releases now to fail patches which have complex subroutines in Perl Files. This would simply be codifying an existing informal rule. David Cook Systems Librarian Prosentient Systems 72/330 Wattle St, Ultimo, NSW 2007
-----Original Message----- From: Christopher Nighswonger [mailto:chris.nighswonger@gmail.com] Sent: Thursday, 1 October 2015 12:58 AM To: Philippe Blouin <philippe.blouin@inlibro.com> Cc: David Cook <dcook@prosentient.com.au>; Tomas Cohen Arazi <tomascohen@gmail.com>; Koha Devel <koha-devel@lists.koha- community.org> Subject: Re: [Koha-devel] Add rule for no subroutines in PL scripts
On Wed, Sep 30, 2015 at 8:20 AM, Philippe Blouin <philippe.blouin@inlibro.com> wrote:
Because the code would be extremely specific to a specific functionality, whereas the code in the libraries is there to be reused. And let not go overboard with OO.
A script is a script is a script. Make it readable, add functions to make it cleaner, make your functions readable.
And make some rule for forbidding direct DB accesses, so that future DB changes do not require to change many scripts. But please, do not forbid functions in scripts.
I tend to agree with Philipee here. It is a bit of an overkill to blanket require a single-script function to be moved over to a library. Perhaps a better approach would be to add some rules which set for the case where functions in scripts should be moved into the appropriate library versus when the definition of functions is acceptable in the script itself.
Kind regards, Chris