title: What design pattern, or anti-pattern?
body: <p>I'll describe what I'm trying to do, and hopefully, somebody can tell me what design pattern this is or point out a better alternative.</p>
  
  <p>I have a method doing a bunch of complicated stuff that involves an approximation. It <em>is</em> possible to compute the result without the approximation but this involves more work.</p>
  
  <p>What I want to do is get out some comparisons related to the inner workings of the implementation. My idea is to pass in an object that would do this extra work and store the info about the comparisons.</p>
  
  <p>I think I want to go from:</p>
  
  <pre><code>class Classifier(object):
      ...
      def classify(self, data):
          # Do some approximate stuff with the data and other
          # instance members.
  </code></pre>
  
  <p>to</p>
  
  <pre><code>class TruthComparer(object):
      def compute_and_store_stats(self, data, accessory_data):
          # Do the exact computation, compare to the approximation,
          # and store it.
  
      def get_comparison_stats(self):
          # Return detailed and aggregate information about the
          # differences between the truth and the approximation.
  
  class Classifier(object):
      ...
      def classify(self, data, truth_comparer=None):
          # Do some approximate stuff with the data and other
          # instance members.
          # Optionally, do exact stuff with the data and other
          # instance members, storing info about differences
          # between the exact computation and the approximation
          # in the truth_comparer
          if truth_comparer is not None:
              truth_comparer.compute_and_store_stats(data,
                                                     [self._index, self._model],
                                                     intermediate_approximation)
  </code></pre>
  
  <p>The reason I don't want to do those comparisons inline within the <code>classify</code> method is that I don't think it fits the job of that method or object to do those comparisons.</p>
  
  <p>So, what design pattern, if any, is this? Can you suggest an alternative?</p>