Design pattern in Python with a lot of customer specific exceptions
<p>At this moment we are working on a large project. </p>

<p>This project is supposed to create EDIFACT messages. This is not so hard at first but the catch is there are a lot of customers that have their own implementation of the standard. </p>

<p>On top of that we are working with several EDIFACT standards (D96A and D01B in our case.)</p>

<p>Some customer exceptions might be as small as having a divergent field length, but some have made their own implementation completely different.</p>

<p>At this moment we have listed the customer exceptions in a list (Just to keep them consistent) and in the code we use something like:</p>

<pre><code>if NAME_LENGTH_IS_100 in customer_exceptions:
    this.max_length = 100
else:
    this.max_length = 70
</code></pre>

<p>For a couple of simple exceptions this works just fine, but at this moment the code starts to get really cluttered and we are thinking about refactoring the code. </p>

<p>I am thinking about some kind of factory pattern, but I am not sure about the implementation. 
Another option would be to create a base package and make a separate implementation for every customer that is diverging from the standard.</p>

<p>I hope someone can help me out with some advice. </p>

<p>Thanks in advance. </p>

<p>Why not put the all this in a resource file with the standard as default and each exception handle in a surcharged value, then you'll just need to read the right key for the right client and you code stay clean.</p>

python