title: Should we strictly adhere set/get rule
body: <p>When I have a public exposed class, I usually make its member variables private, together with public accessors and mutators (I try to avoid mutators if possible to make my class immutable). </p>
  
  <p>For example, </p>
  
  <pre><code>public class Point {
      private final int x;
      private final int y;
  
      public Point(int x, int y) {
          this.x = x;
          this.y = y;
      }
  
      public int getX() {
          return x;
      }
  
      public int getY() {
          return y;
      }
  } 
  </code></pre>
  
  <p>If the class is for private usage, I will usually</p>
  
  <pre><code>private static class Point {
      public final int x;
      public final int y;
  
      public Point(int x, int y) {
          this.x = x;
          this.y = y;
      }
  }
  </code></pre>
  
  <p>As I find the 2nd way is much more convenient for me. Less cumbersome and less typing, although a good IDE may help.</p>
  
  <p>I was wondering, if I have a class for public consumption, is it good that I am using the 2nd approach? (By ensuring my public exposed field will be immutable). </p>
  
  <p>Any shortcoming out from it? Although it seems to violate OOP encapsulation theory, I didn't see a real harm from practical point of view.</p>