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.

As for tests, writing them for very complicated, very very specific function only applicable to a script could have value, but it certainly does not balance the extra complexity your bringing to the code.

Philippe Blouin,
Responsable du développement informatique

Tél.  : (888) 604-2627
philippe.blo...@inlibro.com <mailto:philippe.blo...@inlibro.com>

inLibro | pour esprit libre | www.inLibro.com <http://www.inLibro.com>
On 09/29/2015 07:35 PM, David Cook wrote:

Philippe, could you explain how it’s more messy to have code in modules?

Generally speaking, I can’t think of a reason why there would be code that is extremely specific to some script. I think the preference these days is to use object oriented code, which does isolate mess, so the code should be in the class.

As Tomas points out, it also makes it more difficult to write unit tests for functions, if it’s isolated in a script with no other way of calling that code.

David Cook

Systems Librarian

Prosentient Systems

72/330 Wattle St, Ultimo, NSW 2007

*From:*Philippe Blouin [mailto:philippe.blo...@inlibro.com]
*Sent:* Wednesday, 30 September 2015 12:52 AM
*To:* Tomas Cohen Arazi <tomasco...@gmail.com>
*Cc:* David Cook <dc...@prosentient.com.au>; koha-devel@lists.koha-community.org
*Subject:* Re: [Koha-devel] Add rule for no subroutines in PL scripts

The alternative would be to add some code extremely specific to some script (like parsing some line of data) into a Koha/ library? Seems more messy.

I like to isolate my mess.

Philippe Blouin,
Responsable du développement informatique

Tél.  : (888) 604-2627
philippe.blo...@inlibro.com <mailto:philippe.blo...@inlibro.com>

inLibro| pour esprit libre |www.inLibro.com <http://www.inLibro.com>

On 09/29/2015 09:24 AM, Tomas Cohen Arazi wrote:

    2015-09-29 9:23 GMT-03:00 Philippe Blouin
    <philippe.blo...@inlibro.com <mailto:philippe.blo...@inlibro.com>>:

        Hi!
        Morning here, maybe my brain is not ignited yet.  But why such
        a rule? (if i understand its meaning correctly).

    Because that way there's no way to properly write unit tests for
    the function. And code gets messy too.

    I'll call for a dev meeting and add this to the agenda.


--
    Tomás Cohen Arazi

    Theke Solutions (http://theke.io <http://theke.io/>)
    ✆+54 9351 3513384
    GPG: B76C 6E7C 2D80 551A C765  E225 0A27 2EA1 B2F3 C15F


_______________________________________________
Koha-devel mailing list
Koha-devel@lists.koha-community.org
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to