title: Is it better to modify an object directly or to return a modified clone of the object?
body: <p>The problem is I can't modify an object I'm writing from inside itself and thus made a clone that I modify and return. However, in other functions I directly modify the object calling the method. I would like, and people have recommended, to keep things consistent and so the user can do anything they like with the returned clone without modifying the actual object.</p>
  
  <p>I HAVE to return a modified clone of the object in certain functions because there's no way around it (that I'm aware of). Along with the question in the title, is it better to have a consistent way of doing things (causing me to return clones for even the slightest change) or is it okay if I have different ways to respond to the user in the same class?</p>
  
  <p>[Edit] Is it better to do this:</p>
  
  <pre><code> public Image fillWithColor(Color fillColor) {
      Image newImage = new Image(this.getWidth(), this.getHeight(), this.getType());
  
      for (int x = 0; x &lt; this.getWidth(); x++) {
          for (int y = 0; y &lt; this.getHeight(); y++) {
              newImage.setPixel(x, y, fillColor.getRGB());
          }
      }
  
      return newImage;
  }
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>public void fillWithColor(Color fillColor) {
      for (int x = 0; x &lt; this.getWidth(); x++) {
          for (int y = 0; y &lt; this.getHeight(); y++) {
              this.setPixel(x, y, fillColor.getRGB());
          }
      }
  }
  </code></pre>