title: Declare field outside/inside method : Sonar Singular Field Rule
body: <p>Sonar is giving me a rule violation for "Singular Field".</p>
  
  <p>I have I class with only one method like this.</p>
  
  <pre><code>public class MyClass{
  
     MyType object;   
  
     public void myMethod(){
           object= aMethod(arg);  //Returns instance for the class MyType 
     }
  
  }
  </code></pre>
  
  <p>Here <strong>myMethod</strong> is called countless times.</p>
  
  <ol>
  <li><p>Am I saving the cost of object creation for <strong>MyType</strong> ?</p></li>
  <li><p>Sonar is telling me to declare <strong>MyType</strong> inside <strong>myMethod</strong>().
  Does this will result in the cost of object creation?</p></li>
  </ol>
  
  <p>Any explanation please....</p>