Groovy on Grails

I’ve been having a dabble with Groovy on Grails and on the whole I’m liking it.

It took me less than 10 minutes from initiating a download to getting a basic but functional CRUD application up and running. This is understandably quite satisfying, but it also raises some concerns.

The prototype I threw together consisted of 4 domain objects. Grails took care of the scaffolding; creating controllers and the appropriate views for each of these. The bundled jetty server meant a painless grails run-app later and I could see the fruits of my (absence of) labour.

Following this, the next thing I looked to was the service layer. Actually, I jumped straight to a web service since all I needed to do to expose one of the domain objects was to install the xfire plug-in (grails install-plugin and the following class:

class ActivityService { 
  static expose=['xfire'] Activity[] 
  getActivities() { 
    Activity.list() as Activity[] 

Pretty neat… Well, except that I now have a domain object constituting part of a web service contract.

Obviously my test application was just that, as test of what grails was all about, not a project exercise, but without even thinking contract first web services went out of the window.

Maybe I’m growing too cynical or conservative, but I can’t help feel that if you make things so easy to do that you hardly need to think about them it makes it easier for bad practices to slip in.

Perhaps if I’d followed my own principals and written a test for what I wanted to do first, which grails seems to provide very good support for, it would not have happened.

Yeah, I think I’ll choose to think that.

comments powered by Disqus