void getter that modifies parameter
<p>I've found some android code (<a href="https://github.com/android/platform_frameworks_base/blob/master/core/java/android/view/Display.java" rel="nofollow">link</a>):</p>

<pre><code>   public void getSize(Point outSize) {
      synchronized (this) {
          updateDisplayInfoLocked();
          mDisplayInfo.getAppMetrics(mTempMetrics, mCompatibilityInfo);
          outSize.x = mTempMetrics.widthPixels;
          outSize.y = mTempMetrics.heightPixels;
      }
   }
</code></pre>

<p>And just wondering - what made the author of this piece to implement it in a such way? (Why does it modify the parameter instead of returning new object? Get-methods are normally dumb, have return values, and don't modify parameters. Am I wrong?)</p>

<p>The only reason I can get from top of my head is - efficiency. User of this method could control the number of Point objects created. But is it a good practice designing such API?</p>

<p>UPD:</p>

<p>I would implement it like this (or smth similar):</p>

<pre><code>   public Point getSize() {
      Point outSize = new Point();
      synchronized (this) {
          updateDisplayInfoLocked();
          mDisplayInfo.getAppMetrics(mTempMetrics, mCompatibilityInfo);
          outSize.x = mTempMetrics.widthPixels;
          outSize.y = mTempMetrics.heightPixels;
      }
      return outSize;
   }
</code></pre>
