Sunday, October 31, 2010

Grails SpringOne 2GX Presentation Summary

This month I had the privilege of attending the SpringOne 2GX conference in Chicago. It was an amazing event for me where I got to meet the leaders in the field and learned many new things.  I primarily went to dive in deep into the latest Groovy and Grails developments, technologies, and trends. This blog serves as a housing place for my notes on each presentation I attended.  At the end of the blog, I have posted the original presentations and made them available.

Grails 1.3 Update
by Graeme Rocher

Industry Usage
  • Grails has 499 plugins
  • Lots of high profile sights such as eHarmony, LinkedIn, Wired, Walmart, Sky, SitOrSquat, Northwestern Memorial Hospital, Many Moons
Grails Tooling
  • Eclipse STS - much improved
  • Unit test improvements - see test reports in console, run integration tests
  • code completion, highlighting errors, gsp completion, tag attribute completion
  • grails command window, auto completion, create apps wizard

 Dependency Management DSL
  • DSL in build config for dependency management
  • Can retrieve plugins from Maven repositories
  • declaratively associate dependencies, transitive dependency resolution
  • Download dependencies automatically
  • Read plugin code from repository SVN directory and directly updates running application
  • no longer have to install plugins on update
  • moving to gradle in 2.0
Testing Plugin Support
  • Support for Geb and Spock - DSL testing frameworks; inspect DOM with jQuery syntax (Geb)
  • Test types and phases
  • Configure which phases to use which testing framework - ex grails test-app unit:spock
  • ability to define global constraints and default mappings in config file
  • new hasOne mapping; opposite of belongsTo; one to one where fk is in child table not the parent
  • named queries - reusable queries which are declared with DSL
  • you can chain queries together; merge them together to be one query; dynamically add new criteria
Param Type Converter
  • params in controller has easy converters like int, bool, number...all null safe
  • NoSQL database support
  • RabbitMq, Gemfire
  • per environment Bootstrap
  • Flex Support
  • new reloading mechanism
  • new JSON builder - more closely resembles end result of JSON
Grails 1.4
  • 1Q 2011
  • latest groovy 1.8, spring 3.1, Hib 3.6, Gorm migration toolkit, Rev engineering, JQuery
Improving Your Groovy Code
by Venkat Subramaniam

Code Smells
  • if you don't refactor or don't change code, you are not agile - unit tests enable refactoring
  • not refactoring results in technical debt
  • long methods
  • not following groovy idioms
  • comments often cover up bad code; good comments say "why"
  • express comments as unit tests
  • Use codenarc
  • other common smells
    • Poor variable names
    • Poor method names
    • Long classes
    • Clever code
    • Duplicated code
    • Unnecessary complexity
GORM Inside and Out
by Jeff Brown

  • 1:m default is Set, can be a List by explicitly declaring it
  • One to many w/o back reference is join table; with back reference fk relationship
  • grails schema-export generates ddl of table structure
  • embedded object for one to one relationship; two objects but one table
  • messages that can be changed; can change languages of messages easily
  • matches keyword for regex
  • create custom validators easily
Dynamic Finders Implementation Exercise
  • did an exercise where we created dynamic finders from scratch
  • jdbc dynamic finder, use sql call
  • implemented method missing with metaclass, took the method called, read the name and added it to an sql statement. Then you returned the rows and returned mapped objects.
Grails Sitemesh and Layouts
by Collin Harrington

  • does what tiles does and much more
  • uses decorator pattern
  • view and layout get meshed together to give consistent look and feel; DRY
How it Works
  • GrailsPageFilter in web.xml - decides if sitemesh will be applied to request
  • GrailsHtmlPageParser - in sitemesh.xml - parses gsp into a page object
  • GrailsLayoutDecoratorMapper - in sitemesh.xml - decides which decorator to use by checking metalayout, static property in controller, url convention, or default layout configured
  • also abides by controller naming convention and directory naming convention
Database Migration in Grails
by Burt Beckwith

  • migrations are difficult and often overlooked
  • we need a way to test database refactorings
  • it should not be large overhead to migrate
  • it is important to back up data and schema when migrating
  • we should version the database just as we do the code
  • roll with your own process
  • use dbCreate = update, bad idea for several reasons
  • use liquibase to help manage migrations
Grails Migration Demo
  • used mySqldb
  • create domain objects Customer and Orders
  • keep the created tables to see tables in DB - use dbCreate = null
  • install liquibase plugin
  • generate changelog; this builds changelog.xml of tables in DB and dumps it to a file
  • run changleog -sync to tell liquibase that code and db are in sync
  • now do a migration by adding an address class to the mix and extracting attributes from Customer
  • run grails gorm-diff script - this diffs the gorm built schema with the current db schema - from this you can derive your migration sql
  • this creates an xml file which is close to changelog.xml. you have to adjust the contents of this file because the tool does not know difference of intent. (ex: drop column from a alter column)
  • backup the database before you do anything
  • run grails migrate.

Gradle - A Better Way to Build
by Han Dokter

  • no messy build scripts - specify the what, gradle figures out how - declarative build entries, avoid scripting
  • gradle embraces unanticipated complex build domain; it is a toolkit, not an api to solve your problems
  • will be built into Grails 2.0
  • the build file, you add task with DSL
  • you extend the default behavior to do what you want
  • add extensions of your own key words easily
Demo Capabilities
  • include a same random file in all spring related jars
  • only produce a subset of jars - ex: production only wants the spring jars to look at
  • use previous ant tasks to build a check sum
  • several different projects use same build script: use 'apply from' DSL tag
Gradle is a Build Integration Tool
  • can reuse ant, import a maven build
  • you can inject properties from an ant build, replace tasks from within gradle
  • enables baby steps of large build migrations; no need for separate branches
  • you can use gradle tasks to test out old build results vs new, a kind of self validation
  • gradle can adopt to any project layout

      RIA in Grails - ZK Framework
      by Jean Barmesh

      ZK framework
      • 150 ui components; deskstop like features modeled on the web
      • event driven framework, similar to JSF model
      • this is different then grails mvc, which is front-controller driven
      • advanced UI features packages for you, ajax built in, drag and drop, charts, fading, all included.
      UI Components
      • UI Components are bound to a server side class
      • Ak has own idioms - .zul file, composer, fascade, comet (like a quartz updater for UI)
      • Composer is like a Controller, you can inject services in it, u can create widgets on the fly, or back widgets with data binding
      • You can use a mix of gsp ui and Zk UI as needed.
      Presentations Attended

      1 comment: