Reputation: 1135
We are revamping a new Service Oriented Architecture using Spring @Autowired by the @Service and @Component annotation.
I have been in the debate with my colleagues for not to have interfaces for each DAO's. Becuase for me it doesn't make any sense, whereas i have strongly support the fact of having Interfaces for Services, because of an abstract view with Autowiring.
This is as follows:
Controller (Consumer) < Service (Interface) by @Autowire annotation
Service Implementation (Implements Service) uses DAO using @Component Or @Repository.
Does my understanding of this architecture is correct or Am I missing really important architectural concept.
Upvotes: 2
Views: 103
Reputation: 6182
By referencing you DAO objects by interface from your services, you will have services that is much easier to write tests for.
Upvotes: 0
Reputation: 15092
I know it doesn't seem likely, but I have had it happen where I wanted to implement a DAO using a different storage technology, or simply using JDBC instead of Hibernate because of a performance problem.
In a large app, everything's an interface. It makes your unit tests more flexible and gives you a better long-term path. The cost is only some extra classes and most IDEs help you maintain them.
Upvotes: 1