I'm trying to design an rest API in spring boot and what to ask about a few design decisions. I am completely confused by the whole difference between DAO vs Repository pattern/design. After hours of reading I still don't really understand the difference between the two or which one is preferred standard for designing API's that make backend connections.
Here's a simply UML diagram to highlight the high level view of the api:
This is how I understand a good architecture of an API. But then I came across this article using repository pattern instead of dao with a specification design. I don't understand why a dao interface can't just have a query
function? Does that break the idea of what a DAO is or something?
My question is: what's the best standard to use in today's day in developing an API in Spring Boot and Java 8
If I understood correctly your question, the whole point of using Spring Service/Repository is to separate the business logic from the Controller to the Service class, and the only thing the Repository will do is DB operations, and you will inject it in your Service. There is no difference between DAO (assuming your DAO is a bunch of code using JPA) and Repository, but with Spring Repository you can use Query Methods, which is awesome!
Any suggestion, feel free!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With