Groovy Talk

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

1 comments

Comments 1 - 1 of 1 previous next Post a comment

Post a comment
Embed Video
Edit your comment Cancel

Favorites, Groups & Events

Groovy Talk - Presentation Transcript

  1. Groovy - What, Why and How?
  2. What is it? • dynamic language running on the JVM • compiles to Java byte-code • interoperable with Java • JSR 241 from 2004 • largely adopted along with Grails 2
  3. Why use it? • low learning curve if you know Java • DSL fluency and Builders • shell+scripting = command line power • Tooling: • groovysh • groovyConsole • SwingPad • Maven • IntelliJ(with Eclipse not far behind) 4
  4. Builders Builders are a way to express tree data structures in a natural and fluent way. MarkupBuilder and SwingBuilder are excellent examples. def writer = new StringWriter() def builder = new MarkupBuilder(writer) builder.string(){ value('hello world') } writer.toString() ... <string> <value>hello world</value> </string> 4
  5. Builders SwingBuilder provides easy ways to define UI and SwingPad is a nice tool for quick prototyping. import java.awt.BorderLayout panel { borderLayout() textField("Change Me!", id:'tf', constraints: BorderLayout.NORTH ) button("change me") } Groovy Demo Time 4
  6. Syntactic Sugar Groovy adds a lot of nice stuff to the existing JDK. • Collection: each(), eachWithIndex(), collect(), flatten(), combinations(), intersection(), disjoint(), sort() • List: first(), last(), pop(), push(), asImmutable(), asSynchronized() • Map: groupBy(), subMap(), toMapString() • File: eachDirMatch(), eachDirRecurse(), eachFileMatch(), withReader(), withWriter() • String: eachLine(), eachMatch(), findAll(), count(), is”XYZ”(), toURI(), toURL(), execute() • And so on...... Groovy Demo Time 4
  7. MOP MetaObjectProgramming allows you to affect the runtime behaviour of classes using various techniques. • map coercion: useful for mocks, alternative to inner classes • AST transforms • @Delegate • @Bindable • @Immutable • @Singleton • ExpandoMetaClass: class level or per instance dynamic methods • @Category and @Mixin Groovy Demo Time 4
SlideShare Zeitgeist 2009

+ The KaptainThe Kaptain Nominate

custom

138 views, 0 favs, 0 embeds more stats

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 138
    • 138 on SlideShare
    • 0 from embeds
  • Comments 1
  • Favorites 0
  • Downloads 2
Most viewed embeds

more

All embeds

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories