Monday, February 4, 2008

Grails Encourages Best Practices

You know how every Apple Mac user says there is something special about the Mac? They can't usually put their finger on it but they say something like "it just does what I expect it" or "it does what is right". Well that's the way I feel about Grails. Recently I wrote my first real tag in Grails and I was just amazed at how it felt and how it does the right thing by encouraging best practices. For starters, writing tag libraries is incredibly easy (Read the Piragua Blog for details on how to write a Grails tag.). So why is this a best practice? Well I have seen a lot of scriptlets written in JSPs that should have been reusable JSP tags. But because it was to difficult or time consuming for a developer to actually spend the time to create a JSP tag or even more difficult yet a JSF component it simply was not done. But with Grails tags it is so simple there is no excuse.

Another example is tag and controller integration tests automatically inject mock request, response and session objects. I have seen many projects with no unit tests for the web components or unit tests that require deploying the application because they do not use mock objects. By automatically including mock objects developers no more have to download and add jars for mock web frameworks or even create instances of the mock objects. This should save time and help improve unit tests.

No comments:

AWS EC2 Hibernate Java SDK v2 Example

I recently wanted to automate the creation of developer VMs in AWS using EC2 instances. To improve the developer experience (DX), I didn...