Do I really need to create interfaces in Spring?

I can tell from real world projects, that it works well without interfaces only having the implementing class. Following the principle “You aren’t gonna need it” (YAGNI), you simplify your code if you follow that rule. Dependency Injection works also well with classes, interfaces are not a requirement for it.

Sure you can write and reuse test implementations, but you can do the same with mocks e.g. with mockito and overwrite the behavior of your implementation class for test cases.

Leave a Comment