110 likes | 246 Views
Introduction to. Prepared by : Vincent Schwarzer, Chih-Hung Hsieh . Java Enterprise Application Development. Structure. The history of Groovy. 2. What is Groovy?. Features & S trengths. 3 . Groovy Builder. 4. Groovy vs. Java OOP. 5 . Common use cases. 6. Short example.
E N D
Introduction to Preparedby: Vincent Schwarzer, Chih-Hung Hsieh Java Enterprise Application Development
Structure The historyof Groovy 2. Whatis Groovy? Features & Strengths 3. Groovy Builder 4. Groovy vs. Java OOP 5. Common usecases 6. Short example Java Enterprise Application Development
The historyof Groovy James Strachanstarteddeveloping Groovy in 2003 Severalversionsreleasedbetween2004 and 2006 Released final versioncalled Groovy 1.0 in 2007 Java Enterprise Application Development
Whatis Groovy? • An agile anddynamiclanguageforthe JVM • Builds upon thestrengthof Java Additional power featuresinspiredbylanguages like Ruby, Python andSmallTalk • Almostzerolearningcurvefor Java Developers • Seamlesslyintegrateswith all existing Java classesandlibraries • Youcanuseitanywhereyoucanuse Java Java Enterprise Application Development
Features & Strengths // oldschool Java code, but also valid Groovy code System.out.println("Hello, world!"); // idiomatic Groovy println "Hello, world!" // dynamic variable definition defname = “Peter" // GStringfeaturingstringinterpolation println "Hello, $name" // => "Hello, Peter" // staticallytyped variable String songName = "Coding in the Name of" println "Nowplaying - $songName" String multiline = """thisis a multiline string. Thereis not needtoembed newlinecharacters in it""" printlnmultiline Java Enterprise Application Development
Features & Strengths // methoddefinition defgreet(name) { println "Hello, $name!" } // methodinvocation greet“Peter" greet(“Peter“) // a list defbeers = [“Becks", “Corona", “Budweiser", “Heineken"] // listaccess println"Myfavouritebeeris ${beers[1]}“ for (i in beers) { println i } // importscanappearanywhereandsupportthecreationofaliases importstaticjava.util.Calendar.getInstanceasnow importjava.sql.DateasSDate Java Enterprise Application Development
Groovy Builder oneuseforbuildersisthegenerationofmarkup: Java Enterprise Application Development
Groovy Builder Result: Java Enterprise Application Development
Groovy vs. Java SimilarcapabilitiestoJava: Defineclasses, interfaces, enums, annotations DifferencestoJava: Classes (andinterfaces etc.) publicbydefault Methodspublicbydefault Property supportwithinclasses (auto-setters/getters) Java Enterprise Application Development
Common usecases Web applicationdevelopment scripting Rapid prototyping As a proof on concept ExploratoryProgramming Test class / methodcapabilities Java Enterprise Application Development
ThankYou Java Enterprise Application Development