Avoid accessing private properties directly from the same class
<p>This is a very simple example where accessing directly could be dangerous</p>

<pre><code>class Something{

      public static final int MAX=123;

      private int prop;     

      final void riskyMethod()
      {
          this.prop=800; //this is wrong
      }    

      final void safeSetProp(int x)
      {
         if(x&lt;MAX) 
         {
            prop=x;
         }
      }

}
</code></pre>

<p>I know it could be done encapsulating "prop" in another class, 
and defining it there as private, but that's a lot of useless code overhead! </p>

<p>Is there a way to force the use of methods to access same class properties?</p>

<p>a keyword? any trick? </p>

<p>I confess I have done things like this to avoid accidental access by the same class</p>

<pre><code>private int IKWIDprop;          //IKWID = I Know What I am Doing
</code></pre>

<p>I am sure you could know a better approach =)</p>

<p>Regards!</p>
