Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the best way to customise parts of an existing Perl program for multiple customers?
    primarykey
    data
    text
    <p>I have an existing Perl application which is deployed to multiple customer sites. Unfortunately, the code has been cloned multiple times to customise it for individual customers. So there are now several complete copies of the code which all have slight (or major) differences.</p> <p>My task is to fix this mess by creating a single, generic code base with customisations for different customers being isolated in their own libraries.</p> <p>The application already has a class hierarchy (with about 120 classes) along the lines of:</p> <pre><code>Control.pm \__ BaseJob.pm \___Job1.pm | |__ Job2.pm | |__ Job3.pm </code></pre> <p>My goal is to be able to customise a specific class or method by modifying only the library for a particular customer.</p> <p>My first instinct is to create sub-classes for anything that needs to be customised for a particular customer. These sub-classes would live in a customer-specific lib directory (one per customer). Then, to customise a class or method for a customer, I would just add a new sub-class to the customer library.</p> <p>For example, if one method in <code>Job2.pm</code> needs to be customised, I might create a subclass <code>CustomJob2</code> which inherits from <code>Job2</code> and contains only the method to be customised. </p> <p>Then in the main program, this:</p> <pre><code>Job2-&gt;some_method(); </code></pre> <p>Becomes:</p> <pre><code>CustomJob2-&gt;some_method(); </code></pre> <p>The problem is that this will break the code for all other customers because they don't have the <code>CustomJob2</code> class in their libraries. It appears I would have to add an empty <code>CustomJob2</code> class to the library for every customer.</p> <p>Is there a better way?</p> <p>The other possibility I've considered is to use overrides instead of sub-classes. The main program would just need a <code>use lib</code> to include the customer library and any methods to be customised would just be re-defined in the library. However this is probably dangerous and not considered best practice.</p> <p>I seek the wisdom of StackOverflow gurus in finding the best approach to this problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload