Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • How are you calling the service? Through a REST interface? Commented Jan 8, 2016 at 17:25
  • 3
    I use that design approach myself rather commonly. My controller (or an underlying composer class) will request data from or send data to the repo, and then pass it to any service classes that need to do processing. No reason to combine data processing classes with data retrieval/management classes, they're different concerns though I know the typical approach is to do it that way. Commented Jan 8, 2016 at 17:27
  • 5
    Meh. If it's a small application and you're just trying to get data from a database, a service layer is a waste of time unless that service layer is part of some public API such as a REST interface. "Is milk good for you or bad for you?" Depends on whether you're lactose intolerant. Commented Jan 8, 2016 at 17:29
  • 5
    There isn't a hard and fast rule that you should have a Controller -> Service -> Repository structure over Controller -> Repository. Pick the right pattern for the right application. What I would say is that you should make your application consistent. Commented Jan 8, 2016 at 17:30
  • 1
    Maybe you could come up with a generic service that only forwards your request to the repository and then returns. This could be useful to keep a uniform interface and would be simple if in the future you need to add a real service to do something before call the repository. Commented Jan 8, 2016 at 19:13