Thursday, April 7, 2011

Groovy style for Java developers

http://groovy.codehaus.org/Groovy+style+and+language+feature+guidelines+for+Java+developers

Optional typing advice

  • Groovy lets you decide whether you use explicit strong typing, or when you use 'def'.
  • Whenever the code you're writing is going to be used by others as a public API, you should always favor the use of strong typing, it:
    • helps making the contract stronger, 
    • avoids possible passed arguments type mistakes, 
    • gives better documentation, 
    • helps the IDE with code completion
  • Whenever the code is for your use only, like private methods, or when the IDE can easily infer the type, then you're more free to decide when to type or not.