magic with groovy & grails

9
© Catalysts GmbH © Catalysts GmbH Magic with Groovy & Grails The Search is over Zalán Borsos

Upload: zalan-borsos

Post on 27-May-2015

213 views

Category:

Technology


2 download

DESCRIPTION

Magic with groovy & grails

TRANSCRIPT

Page 1: Magic with groovy & grails

© Catalysts GmbH

© Catalysts GmbH

Magic with Groovy & GrailsThe Search is over

Zalán Borsos

Page 2: Magic with groovy & grails

© Catalysts GmbH

What is Groovy?• Dynamic language• 1.0 released on 02.01.2007• Dynamically compiled to JVM bytecode• 99% of Java code is also valid• Groovy = Java +

dynamic typing +

additional methods & operators +

closures

Page 3: Magic with groovy & grails

© Catalysts GmbH

If we indent code properly,why do we need semicolons?

Page 4: Magic with groovy & grails

© Catalysts GmbH

Dynamic TypingJavaArrayList<String> list = new ArrayList<String>() {

{add("A");add("B");add("C");

}};

HashMap<Integer, String> map = new HashMap<Integer, String>() {

{put(1, "A");put(2, "B");put(3, "C");

}};

Groovy

?

Page 5: Magic with groovy & grails

© Catalysts GmbH

Additional Operators• Spread *.• Elvis ?:• Safe navigation ?.• Equals ==

Page 6: Magic with groovy & grails

© Catalysts GmbH

Closures“A Groovy Closure is like a ‘code block’ or a method pointer. It is a piece of code that is defined and then executed at a later point.”

http://groovy.codehaus.org/Closures

Page 7: Magic with groovy & grails

© Catalysts GmbH

Functional Programming• Closures as functions• Closures as function compositions• Fibonacci

Page 8: Magic with groovy & grails

© Catalysts GmbH

What is Grails?• Web application framework• Convention over consideration• Spring MVC• Fast prototyping and development

Page 9: Magic with groovy & grails

© Catalysts GmbH