Java Style / Best Practice - passing fields to methods vs accessing directly
<p>In Java, given the following class:</p>

<pre><code>public class MyClass {
   private final Dependency dependency;
   public MyClass(Dependency dependency)
   {
       this.dependency = dependency;
   }

   public void doWork()
   {
       // validate dependency...
   }
</code></pre>

<p>The doWork method needs to invoke a method that uses <code>dependency</code>.</p>

<p>Which of the following two variations is considered "best practice", and why?</p>

<pre><code>   // Access dependency directly
   void validateDependency()
   {
        this.dependency.something();
   }

   // access dependency as passed to the method
   void validateDependency(Dependency dependency)
   {
       dependency.something();
   }
</code></pre>

<p>I find myself favouring the latter, passing the dependency directly to the method, as it makes the method easier to test in isolation (albeit, marginally).</p>

<p>However, I'm interested in the java convention / best practice here.</p>
