<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style id="owaParaStyle">P {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
</style>
</head>
<body bgcolor="#ffffff" fPStyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<p>I could understand that Philippe would write a sub in a script.</p>
<p>If we forbid that, we could [theoretically] get here:  Better write hard code in one big chunk and call it a script (without unit tests) than provide good code with some subs that have no real meaning outside the script and therefore do not need a module..</p>
<p>We should handle this more pragmatically imo..</p>
<p> </p>
<div style="FONT-SIZE: 16px; FONT-FAMILY: Times New Roman; COLOR: #000000">
<hr tabindex="-1">
<div id="divRpF679403" style="DIRECTION: ltr"><font color="#000000" size="2" face="Tahoma"><b>Van:</b> koha-devel-bounces@lists.koha-community.org [koha-devel-bounces@lists.koha-community.org] namens Philippe Blouin [philippe.blouin@inlibro.com]<br>
<b>Verzonden:</b> woensdag 30 september 2015 14:20<br>
<b>Aan:</b> David Cook; 'Tomas Cohen Arazi'<br>
<b>CC:</b> koha-devel@lists.koha-community.org<br>
<b>Onderwerp:</b> Re: [Koha-devel] Add rule for no subroutines in PL scripts<br>
</font><br>
</div>
<div></div>
<div>
<div class="moz-cite-prefix">Because the code would be extremely specific to a specific functionality, whereas the code in the libraries is there to be reused.<br>
And let not go overboard with OO.<br>
<br>
A script is a script is a script.  Make it readable, add functions to make it cleaner, make your functions readable.<br>
<br>
And make some rule for forbidding direct DB accesses, so that future DB changes do not require to change many scripts.<br>
But please, do not forbid functions in scripts.<br>
<br>
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.<br>
<br>
<div class="moz-signature"><style type="text/css">.moz-signature {
        COLOR: #ffffff
}
.sig_inlibro {
        FONT-SIZE: 90%; FONT-FAMILY: "Trebuchet MS",verdana; COLOR: #888888; PADDING-TOP: 2px
}
.sig_content {
        BORDER-TOP: #dddddd 2px solid; BORDER-BOTTOM: #bfd13d 2px solid; PADDING-LEFT: 10px; BACKGROUND-COLOR: #f6f6f6
}
.sig_inlibro A:visited {
        TEXT-DECORATION: none; COLOR: #005b85
}
.sig_inlibro A:hover {
        TEXT-DECORATION: none; COLOR: #005b85
}
.sig_inlibro A:link {
        TEXT-DECORATION: none; COLOR: #005b85
}
.nom {
        FONT-WEIGHT: bold; COLOR: #005b85
}
.inlibro {
        COLOR: #bfd13d
}
.in {
        COLOR: #bfd13d
}
.libro {
        COLOR: #005b85
}
.in {
        FONT-SIZE: 120%
}
.libro {
        FONT-SIZE: 120%
}
.desc {
        MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 5px
}
.small {
        FONT-SIZE: 80%
}
.tagline {
        COLOR: #00bce4
}
.sig_footer {
        PADDING-LEFT: 10px; BACKGROUND-COLOR: #eeefea
}
</style>
<div class="sig_inlibro">
<div class="sig_content"><span class="nom">Philippe Blouin,</span><br>
<span class="tagline small">Responsable du développement informatique</span><br>
<p class="desc small">Tél.  : (888) 604-2627<br>
<a href="mailto:philippe.blouin@inLibro.com" target="_blank">philippe.blouin@inLibro.com</a>
</p>
</div>
<div class="sig_footer"><span class="in">in</span><span class="libro">Libro</span>
<span class="tagline small">| pour esprit libre |</span> <a class="small" href="http://www.inLibro.com" target="_blank">
www.inLibro.com</a> </div>
</div>
</div>
On 09/29/2015 07:35 PM, David Cook wrote:<br>
</div>
<blockquote type="cite"><style>@font-face {
        font-family: Cambria Math;
}
@font-face {
        font-family: Calibri;
}
@font-face {
        font-family: Trebuchet MS;
}
@font-face {
        font-family: Segoe UI Symbol;
}
@page WordSection1 {margin: 72.0pt 72.0pt 72.0pt 72.0pt; }
P.MsoNormal {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: black; MARGIN: 0cm 0cm 0pt
}
LI.MsoNormal {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: black; MARGIN: 0cm 0cm 0pt
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: black; MARGIN: 0cm 0cm 0pt
}
A:link {
        TEXT-DECORATION: underline; COLOR: blue
}
SPAN.MsoHyperlink {
        TEXT-DECORATION: underline; COLOR: blue
}
A:visited {
        TEXT-DECORATION: underline; COLOR: purple
}
SPAN.MsoHyperlinkFollowed {
        TEXT-DECORATION: underline; COLOR: purple
}
P.moz-signature {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: white; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
LI.moz-signature {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: white; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.moz-signature {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: white; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
P.siginlibro {
        FONT-SIZE: 11pt; FONT-FAMILY: "Trebuchet MS",sans-serif; COLOR: #888888; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
LI.siginlibro {
        FONT-SIZE: 11pt; FONT-FAMILY: "Trebuchet MS",sans-serif; COLOR: #888888; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.siginlibro {
        FONT-SIZE: 11pt; FONT-FAMILY: "Trebuchet MS",sans-serif; COLOR: #888888; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
P.sigcontent {
        FONT-SIZE: 12pt; BORDER-TOP: medium none; FONT-FAMILY: "Times New Roman",serif; BORDER-RIGHT: medium none; BACKGROUND: #f6f6f6; BORDER-BOTTOM: medium none; COLOR: black; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; PADDING-LEFT: 0cm; MARGIN-LEFT: 0cm; BORDER-LEFT: medium none; PADDING-RIGHT: 0cm; MARGIN-RIGHT: 0cm
}
LI.sigcontent {
        FONT-SIZE: 12pt; BORDER-TOP: medium none; FONT-FAMILY: "Times New Roman",serif; BORDER-RIGHT: medium none; BACKGROUND: #f6f6f6; BORDER-BOTTOM: medium none; COLOR: black; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; PADDING-LEFT: 0cm; MARGIN-LEFT: 0cm; BORDER-LEFT: medium none; PADDING-RIGHT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.sigcontent {
        FONT-SIZE: 12pt; BORDER-TOP: medium none; FONT-FAMILY: "Times New Roman",serif; BORDER-RIGHT: medium none; BACKGROUND: #f6f6f6; BORDER-BOTTOM: medium none; COLOR: black; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; PADDING-LEFT: 0cm; MARGIN-LEFT: 0cm; BORDER-LEFT: medium none; PADDING-RIGHT: 0cm; MARGIN-RIGHT: 0cm
}
P.nom {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; FONT-WEIGHT: bold; COLOR: #005b85; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
LI.nom {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; FONT-WEIGHT: bold; COLOR: #005b85; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.nom {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; FONT-WEIGHT: bold; COLOR: #005b85; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
P.inlibro {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #bfd13d; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
LI.inlibro {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #bfd13d; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.inlibro {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #bfd13d; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
P.in {
        FONT-SIZE: 14.5pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #bfd13d; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
LI.in {
        FONT-SIZE: 14.5pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #bfd13d; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.in {
        FONT-SIZE: 14.5pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #bfd13d; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
P.libro {
        FONT-SIZE: 14.5pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #005b85; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
LI.libro {
        FONT-SIZE: 14.5pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #005b85; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.libro {
        FONT-SIZE: 14.5pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #005b85; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
P.desc {
        MARGIN-BOTTOM: 0pt; FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: black; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
LI.desc {
        MARGIN-BOTTOM: 0pt; FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: black; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.desc {
        MARGIN-BOTTOM: 0pt; FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: black; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
P.small {
        FONT-SIZE: 9.5pt; FONT-FAMILY: "Times New Roman",serif; COLOR: black; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
LI.small {
        FONT-SIZE: 9.5pt; FONT-FAMILY: "Times New Roman",serif; COLOR: black; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.small {
        FONT-SIZE: 9.5pt; FONT-FAMILY: "Times New Roman",serif; COLOR: black; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
P.tagline {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #00bce4; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
LI.tagline {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #00bce4; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.tagline {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; COLOR: #00bce4; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
P.sigfooter {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; BACKGROUND: #eeefea; COLOR: black; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
LI.sigfooter {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; BACKGROUND: #eeefea; COLOR: black; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
DIV.sigfooter {
        FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman",serif; BACKGROUND: #eeefea; COLOR: black; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm
}
SPAN.nom1 {
        FONT-WEIGHT: bold; COLOR: #005b85
}
SPAN.tagline1 {
        COLOR: #00bce4
}
SPAN.in1 {
        COLOR: #bfd13d
}
SPAN.libro1 {
        COLOR: #005b85
}
SPAN.EmailStyle32 {
        FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext
}
.MsoChpDefault {
        FONT-SIZE: 10pt
}
</style>
<div class="WordSection1">
<p class="MsoNormal"><a name="_MailEndCompose"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext">Philippe, could you explain how it’s more messy to have code in modules?
</span></a></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext"></span> </p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext">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.
</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext"></span> </p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext">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.</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext"></span> </p>
<div>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext">David Cook</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext">Systems Librarian</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext">Prosentient Systems</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext">72/330 Wattle St, Ultimo, NSW 2007</span></p>
</div>
<p class="MsoNormal"><span style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext"></span> </p>
<div style="BORDER-TOP: medium none; BORDER-RIGHT: medium none; BORDER-BOTTOM: medium none; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; PADDING-LEFT: 4pt; BORDER-LEFT: blue 1.5pt solid; PADDING-RIGHT: 0cm">
<div>
<div style="BORDER-TOP: #e1e1e1 1pt solid; BORDER-RIGHT: medium none; BORDER-BOTTOM: medium none; PADDING-BOTTOM: 0cm; PADDING-TOP: 3pt; PADDING-LEFT: 0cm; BORDER-LEFT: medium none; PADDING-RIGHT: 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext">From:</span></b><span lang="EN-US" style="FONT-SIZE: 11pt; FONT-FAMILY: "Calibri",sans-serif; COLOR: windowtext"> Philippe Blouin [<a class="moz-txt-link-freetext" href="mailto:philippe.blouin@inlibro.com" target="_blank">mailto:philippe.blouin@inlibro.com</a>]
<br>
<b>Sent:</b> Wednesday, 30 September 2015 12:52 AM<br>
<b>To:</b> Tomas Cohen Arazi <a class="moz-txt-link-rfc2396E" href="mailto:tomascohen@gmail.com" target="_blank">
<tomascohen@gmail.com></a><br>
<b>Cc:</b> David Cook <a class="moz-txt-link-rfc2396E" href="mailto:dcook@prosentient.com.au" target="_blank">
<dcook@prosentient.com.au></a>; <a class="moz-txt-link-abbreviated" href="mailto:koha-devel@lists.koha-community.org" target="_blank">
koha-devel@lists.koha-community.org</a><br>
<b>Subject:</b> Re: [Koha-devel] Add rule for no subroutines in PL scripts</span></p>
</div>
</div>
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">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.<br>
<br>
I like to isolate my mess.</p>
<div>
<div>
<div style="BORDER-TOP: #dddddd 1.5pt solid; BORDER-RIGHT: medium none; BORDER-BOTTOM: #bfd13d 1.5pt solid; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; PADDING-LEFT: 0cm; BORDER-LEFT: medium none; PADDING-RIGHT: 0cm">
<p class="MsoNormal" style="BACKGROUND: #f6f6f6"><span class="nom1"><span>Philippe Blouin,</span></span><span><br>
</span><span class="tagline1"><span>Responsable du développement informatique</span></span><span></span></p>
<p class="desc" style="BACKGROUND: #f6f6f6"><span>Tél.  : (888) 604-2627<br>
<a href="mailto:philippe.blouin@inLibro.com" target="_blank"><span style="TEXT-DECORATION: none; COLOR: #005b85">philippe.blouin@inLibro.com</span></a>
</span></p>
</div>
<div>
<p class="MsoNormal" style="BACKGROUND: #eeefea"><span class="in1"><span>in</span></span><span class="libro1"><span>Libro</span></span><span>
</span><span class="tagline1"><span>| pour esprit libre |</span></span><span> <a href="http://www.inLibro.com" target="_blank">
<span style="FONT-SIZE: 9pt; TEXT-DECORATION: none; COLOR: #005b85">www.inLibro.com</span></a>
</span></p>
</div>
</div>
</div>
<p class="MsoNormal">On 09/29/2015 09:24 AM, Tomas Cohen Arazi wrote:</p>
</div>
<blockquote style="MARGIN-BOTTOM: 5pt; MARGIN-TOP: 5pt">
<div>
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal">2015-09-29 9:23 GMT-03:00 Philippe Blouin <<a href="mailto:philippe.blouin@inlibro.com" target="_blank">philippe.blouin@inlibro.com</a>>:</p>
<blockquote style="BORDER-TOP: medium none; BORDER-RIGHT: medium none; BORDER-BOTTOM: medium none; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; PADDING-LEFT: 6pt; MARGIN-LEFT: 4.8pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-RIGHT: 0cm; MARGIN-RIGHT: 0cm">
<div>
<div>
<p class="MsoNormal">Hi!<br>
Morning here, maybe my brain is not ignited yet.  But why such a rule? (if i understand its meaning correctly).</p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Because that way there's no way to properly write unit tests for the function. And code gets messy too.</p>
</div>
<div>
<p class="MsoNormal">I'll call for a dev meeting and add this to the agenda.</p>
</div>
</div>
<p class="MsoNormal"><br clear="all">
</p>
<div>
<p class="MsoNormal"> </p>
</div>
<p class="MsoNormal">-- </p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="FONT-SIZE: 9.5pt">Tomás Cohen Arazi</span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-SIZE: 9.5pt">Theke Solutions (<a href="http://theke.io/" target="_blank">http://theke.io</a>)<br>
</span><span>✆</span><span style="FONT-SIZE: 9.5pt"> +54 9351 3513384<br>
GPG: B76C 6E7C 2D80 551A C765  E225 0A27 2EA1 B2F3 C15F</span></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p class="MsoNormal"> </p>
</div>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</body>
</html>