1

I am a bit confused on the difference between using Grails domain model/service to inlcude my biz logic or make my Grails controller/services to talk to my application server and make the web layer separate from the application logic layer?

  1. When do I select which?
  2. What are the pros and cons of each approach?
  3. Any gotcha using the Grails domain stuff specially for scalability and what not?
iCode
  • 4,308
  • 10
  • 44
  • 77

1 Answers1

0

If you already have a web service that handles your domain and business rules, you can turn off db support.

If you do that, your grails app is effectively a thin web layer on top of another service. In this case, if you are going to enforce business rules, you could still do it in service/domain layers. However, I would not do this, and certainly not any complex validation, because the service should be your single source of truth for the app, and you don't want to duplicate business rules in 2 apps.

I would still use controllers for handling web requests, and services for interacting with the other service. I would also have some sort of simple domain layer for passing data thru the sections of the web layer (i.e. services return anemic domain objects, controllers serialize them to the client however makes sense). The majority of the work would be in the service layer, which would serialize and deserialize the communication with the other service.

Based on your comment, Grails is a fine technology for building your server layer. Why would you think it isn't? Grails bills itself as a rapid development environment; it provides everything you need for all layers of a standard web-app. You don't lose anything; quite the contrary, you gain quite a bit, such a integration with persistence, spring, a robust testing framework, etc.

Community
  • 1
  • 1
hvgotcodes
  • 118,147
  • 33
  • 203
  • 236
  • I understand that and I do not have the app server yet. My question is really around if there is any value to have an independent app server layer vs having everything in Grails. In other words, I wanna know if I may lose important controls over my system if choose to use Grails instead of separate app server layer? I mean maybe having separate application help with scalability ?! – iCode May 15 '13 at 19:16
  • Thanks for the note. I am new to web development(have been a back-end guy) and want to make sure I am taking the right decision. Do you recommend to use Grails to serve my pages and also act as my public REST API server? – iCode May 15 '13 at 20:08
  • Certainly for a first go, it can do such things. Make sure to write your code modularly so you can build jars that handle the major functionality. That way if it makes sense for the public API to be in its own app, you can easily build it up using existing code. – hvgotcodes May 15 '13 at 20:36