java - Why the need for a strict enforcement of interfaces for classes in a Spring MVC service layer? -


I'm working in the Spring Web App, a service layer that relates to the rest of the web app architecture this service level interface And the implementation is made up of sections.

  com / myapp / controller / model / service /  

P> Why is it so important to interfaces for all these sections?

Why not just class files?

Interface allows you to perform various implementations of those interfaces without changing the underlying code. For example, if a model wanted only a hashmap and you had a trademark, then you would be in trouble. But if the model accepted the map (well, then it is pretending to be an interface), then it will work with a hashmap or a trademark.


Comments