<?xml version="1.0" encoding="windows-1252"?>
<node id="1001416" title="Re: subroutine good practise" created="2012-10-29 16:18:55" updated="2012-10-29 16:18:55">
<type id="11">
note</type>
<author id="647953">
sundialsvc4</author>
<data>
<field name="doctext">
&lt;p&gt;
In my opinion, when a program is constructed in such a very &amp;ldquo;dynamic&amp;rdquo; way &lt;i&gt;(for what purpose? &amp;nbsp; &amp;ldquo;efficiency?&amp;rdquo;)&lt;/i&gt;, it becomes utterly impossible to &lt;b&gt;test&lt;/b&gt; it. &amp;nbsp; It becomes, in effect, many different possible programs, depending on (as you say) &amp;ldquo;how it is called.&amp;rdquo; &amp;nbsp; This practice is completely unacceptable to me, due to the inherent business risk.
&lt;/p&gt;&lt;p&gt;
In my experience, most such programs can be, perhaps with some effort, &amp;ldquo;de-fused&amp;rdquo; into one or more modules of common-code which can then be &lt;tt&gt;use&lt;/tt&gt;d by the specific in-house script that invokes them. &amp;nbsp; These scripts ought not attempt to make any decisions as to what code they do or do not invoke, and they should universally use &lt;tt&gt;use&lt;/tt&gt; to do so. &amp;nbsp; (This is not, of course, an impregnable requirement, but IMHO it is very nearly so. &amp;nbsp; Obvious exceptions such as [mod://RPC::Any::Server] are also very-limited in what they do and how they do it, and the &lt;tt&gt;require&lt;/tt&gt;d modules are also clearly &amp;ldquo;top-level handlers,&amp;rdquo; effectively selecting &lt;em&gt;among&lt;/em&gt; possible scripts to call; not the case here.)
&lt;/p&gt;&lt;p&gt;
Any piece of software that is in service needs to be buttressed by independent, automated tests that can demonstrate that, in every case which that piece of software supports, the software works correctly. &amp;nbsp; If &lt;em&gt;what the piece of software is &lt;u&gt;composed&lt;/u&gt; of&lt;/em&gt; is subject to variation, that becomes pragmatically impossible to do. &amp;nbsp; What a group of scripts have in common, reasonably should be in-common, so that the common pieces can be tested and the tests will cover all of that code&amp;rsquo;s users. &amp;nbsp; If thereby the program contains code that it does not make use of in the course of any particular invocation ... who cares. &amp;nbsp; Such is of no consequence.
&lt;/p&gt;</field>
<field name="root_node">
1001398</field>
<field name="parent_node">
1001398</field>
</data>
</node>
