Implementing a service layer
We have been handling several different HTTP verbs in our implementation, and this is okay, but in doing so, we create some duplication in our code that we may need to remove. For example, updating our customer was combining what our delete and create do.
But there is another thing that we haven't noticed. In a way, we are coupling our API handling, our controller, too, however, our model is stored, making the customer bean a part of our controller that has created that coupling.
Right now, our customers' list is a map, tomorrow, we may want to store it in a database, or handle in a different way, affecting our controller for that to not look right. We are going to use the service pattern for handling this problem. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access