Skip to main content
9 events
when toggle format what by license comment
Jun 22, 2024 at 17:28 comment added Charles Wood @Rober2D2 Bear in mind that this question is not tagged with a specific language or framework, so it may not be a given to the reader that services are needed for transaction control.
Jun 22, 2024 at 17:26 comment added Charles Wood A downside to "wait until you need it" for wrapper classes (such as a service layer that only calls the repository) is that when the business logic eventually comes along, you may have ended up with hundreds of calls to the repository that now need to be wrapped and regression tested. Obviously if the business logic never comes along, you've saved some boilerplate, but it's a tradeoff worth thinking about.
Jun 5, 2023 at 8:58 comment added Rober2D2 Simple services are not useless. They provide transactional control. I prefer to always call services with @Transactional anotation to prevent erratic Hibernate behaviours. For example, to prevent Hibernate to automatically persist entities that I read directly from DAOs.
Oct 28, 2022 at 7:34 comment added James You should only write a service class if it does more just be a go between. Service should catch exceptions, deal with empty or null responses, get additional data that Repo requires, like call other repos for data so repo itself doesn't call other repos, etc. Controller shouldn't do heavy lifting but calling a Repo class is not heavy lifting
Dec 1, 2021 at 19:42 comment added GHOST-34 I think it really depends on the project complexity as well as team. If the operations are basically just CRUD most likely just access the repo. More complex business logic would eventually demand a service and logic can be abstracted there. But perhaps your team is very junior and your app could scale. Even if it's currently just a simple CRUD app, I might still require a service layer even if its just a pass through to help describe the architecture and ensure SRP is highlighted. When the demand for it comes along, there's little to no confusion of where it should go.
Nov 29, 2021 at 19:19 comment added Trace If the service does nothing else than calling a method on the repository, adding a Service is pretty useless.
Mar 15, 2020 at 17:20 history edited Izhari Ishak Aksa CC BY-SA 4.0
deleted 1 character in body
Mar 15, 2020 at 17:20 review First posts
Mar 16, 2020 at 16:21
Mar 15, 2020 at 17:15 history answered Izhari Ishak Aksa CC BY-SA 4.0