2

I have a Grails application with a number of services that are starting to get very large.

The flow in the majority of my service methods is

  1. Database read (Returns DBCursor from MongoDB)
  2. Iterate through the cursor and perform some operations.
  3. Return results from operation.

I'm beginning to consider moving the logic in Step 2 out to Groovy classes in order to clean up my code base and allow for unit testing. However reading some guidelines they state that the majority of the logic should go in services.

Is moving this logic out to Groovy classes going aghainst best practices?

Travis
  • 135
  • 5

1 Answers1

3

Usually that type of guideline (that the majority of the logic should go in services) means that your business logic should be accessible through services rather than e.g. in an MVC controller. A service should be the interface to some business logic, but all the code implementing that business logic doesn't necessarily have to live in a service class.

Mike Partridge
  • 6,587
  • 1
  • 25
  • 39