Friday, August 19, 2011

A Pattern to Simplify Grails Controllers « Mr Paul Woods's Weblog

A Pattern to Simplify Grails Controllers « Mr Paul Woods's Weblog
I generally follow the same patterns with my controllers. They start with “the big 7 actions” – closures for index, list, show, create, save, edit, update and delete. Then i include any necessary controller-specific actions. After unit testing my controllers for the up-teenth time, I realized that there is a consistent pattern for many of the actions – get the id from params, get the domain object, then use the domain object. I wanted to extract this pattern into its own method, and that extraction evolved into the “WithDomainObject” pattern.

No comments:

Post a Comment