title: getters and setters performing additional logic
body: <p>I have a Java class which represents the correlation between two elements (typical POJO):</p>
  
  <pre><code>public class Correlation {
  
      private final String a;
      private final String b;
  
      private double correlation;
  
      public Correlation(String a, String b) {
          this.a = a;
          this.b = b;
      }
  
      public double getCorrelation() {
          return correlation;
      }
  
      public void setCorrelation(double correlation) {
          this.correlation = correlation;
      }
  
  }
  </code></pre>
  
  <p>To follow the correct correlation logic if a equals b then the correlation value should be ALWAYS 1.
  I could add the logic altering the getter method (ignore the fact of the possible null value for a):</p>
  
  <pre><code>public double getCorrelation() {
      if (a.equals(b)) {
          return 1D;
      } else {
          return correlation;
      }
  }
  </code></pre>
  
  <p>What bothers me is adding this logic to a getter method, should I change the method name or  documenting it should be considered enough?</p>