Announcement Announcement Module
Collapse
No announcement yet.
groovy/grails coding standards Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • groovy/grails coding standards

    Hello,

    Groovy programming language has very flexible syntax, a lot of stuff is optional: optional typing, semicolons, etc.
    We are investigating Grails as a mainstream development platform for our company and see the need for strict coding standards to be in place for Grails based apps. We are afraid that without this some developers would be adding semicolons some not and after a while code base will become quite inconsistent and messy.
    In PHP world ZendFramework has dedicated entire section in documentation to coding standards to avoid these inconsistencies.
    http://framework.zend.com/manual/en/...-standard.html
    People that create new extensions for Zend stick to that and the entire code base has more less the same style.

    Is there something similar for Grails framework, official recommendations/coding standards.
    This would be valuable for people creating Grails plugins and apps.

    Cheers,
    Klekot

  • #2
    There isn't no. The Sun Java style is a good starting point. Other things to consider:

    * Whether to use explicit returns or not
    * Whether to use explicit arguments in closures
    * Whether to declare explicit types for method/closure arguments
    * Semi-colons or not
    * def or explicit types for local variables

    I tend to prefer explicit returns and closure arguments unless the closure is inlined, e.g. list.find {it.hasErrors() }. No semi-colons for me and I tend to use def for all local variables.

    Fields I sometimes type, sometimes not. Don't forget that declaring explicit types helps the IDEs a lot, so it can be worth it.

    Comment

    Working...
    X