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.
Example:
Class Car{
@Autowired
private IEngine engine;
}
Class Engine{}
Interface IEngine{}
vs
Class Car{
@Autowired
private Engine engine;
}
Class Engine{}