title: why are interfaces recommended for spring beans?
body: <p>I'm learning Spring and ran into this design question. I'm not sure how to interpretate it. Should I always use an interface instead of just pointing to the actual implementation when linking beans? I imagine it becomes easier to test from a mocking perspective but should I follow it dogmatically? ie a bean should always refer the interface of another bean. </p>
  
  <p>Example: </p>
  
  <pre><code>Class Car{
      @Autowired
      private IEngine engine;
  }
  
  Class Engine{}
  
  Interface IEngine{}
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>Class Car{
      @Autowired
      private Engine engine;
  }
  
  Class Engine{}
  </code></pre>