SlideShare ist ein Scribd-Unternehmen logo
1 von 53
Groovy og Grails  for Javaudviklere
Søren Berg Glasius ,[object Object]
Javaudvikler siden 2000
Ansat hos  Gennemtænkt IT ,[object Object]
Benytter  Grails  som platform til produkt ,[object Object]
Stifter af  GR8Conf  – en konference for Groovy et al.
Passioneret  bruger af Groovy og Grails
Twitter: @sbglasius
Agenda ,[object Object]
Obligatoriske ”Hello World”
Syntax og syntaktisk sukker
Groovy API (GDK) ,[object Object],[object Object]
Spock ,[object Object],[object Object]
Live coding! ,[object Object],10 min. pause
Groovy - Overblik ,[object Object]
Open Source (BSD / Apache licens)
Dynamisk sprog på JVM'en
Grammatik videreudviklet fra Java
Inspireret af Python, Ruby og Smalltalk
Flad indlæringkurve for Java-udviklere Java på Steroider!
Et dynamisk sprog ,[object Object]
def i = 0 // Tildel integer i = ”streng” // skift til streng
Et Java-eksempel public class UsingJava { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return "Using Java " + getName(); } public static void main(String[] args) { UsingJava usingJava = new UsingJava(); usingJava.setName("Geeks"); System.out.println(usingJava); } }
Et Java-eksempel
Et Java-eksempel Groovyfied class GettingGroovy { String name @Override String toString() { "Get Groovy $name" } }  println new GettingGroovy(name: "Geeks")
public class HelloWorld { private String name; public String getName() { return name; } public void setName(String name) { this.name=name; } @Override public String toString() { return "Hello "+getName(); } public static void main(String[] args) { HelloWorld helloWorld = new HelloWorld(); helloWorld.setName("Geeks"); System.out.println(helloWorld); } } Java vs. Groovy class GettingGroovy { String name String toString() { "Get Groovy $name" } }  println new GettingGroovy(name: "Geeks") Færre linier kode  Færre mulighed for fejl! 18 linier kode 7 linier kode 60% mindre Kode!
Collections ,[object Object]
Groovy Lists def list = [ "String 1","String 2" ]  assert list[0] == "String 1"  assert list.get(0) == "String 1" assert list.size == 2 List list = Arrays.asList("String 1", "String 2"); assert(list.get(0).equals("String 1")); assert(list.size()==2);
Collections ,[object Object]
Groovy Maps def map = [key1:"Value 1",key2: "Value 2"] assert !map.containsKey("key3") && !map["key3"] && !map.key3 assert map.key1 assert map.key1=="Value 1" assert map.size() == 2 Map map = new HashMap(); map.put("Key 1","Value 1"); map.put("Key 2","Value 2"); assert(!map.containsKey("Key 3")); assert(map.containsKey("Key 1")); assert(map.get("Key 1").equals("Value 1")); assert(map.size() == 2);
Lists ,[object Object],def list = [&quot;s1&quot;,&quot;s2&quot;,&quot;s3&quot;,&quot;s4&quot;,&quot;s5&quot;] assert list[2..3] == ['s3','s4'] assert list[3..2] == ['s4','s3'] assert list[-1] == 's5' assert list[-2] == 's4' assert list[3..-1] == ['s4','s5'] List list = Arrays.asList(&quot;s1&quot;,&quot;s2&quot;,&quot;s3&quot;,&quot;s4&quot;,&quot;s5&quot;); assert list.subList(2,4).equals(Arrays.asList(&quot;s3&quot;,&quot;s4&quot;)); List<String> reversed = list.subList(2,4); Collections.reverse(reversed); assert reversed.equals(Arrays.asList(&quot;s4&quot;,&quot;s3&quot;)); assert list.get(list.size())==&quot;s5&quot;; assert list.subList(3,list.size())==Arrays.asList(&quot;s4&quot;,&quot;s5&quot;);
Unificering ,[object Object]
Med Groovy: public static void main(String[] args) { String string = &quot;String&quot;; String[] array = new String[] {&quot;String1&quot;,&quot;String2&quot;}; Map<String,String> map = new HashMap<String,String>();  map.put(&quot;Key1&quot;,&quot;Val1&quot;); List<String> list = new ArrayList<String>(); list.add(&quot;String1&quot;); assert string. length() ==6; assert array. length  == 2; assert map. size() ==1; assert list. size() ==1; } def string = &quot;String&quot;, array = [&quot;String1&quot;,&quot;String2&quot;] def map = [Key1:&quot;Val1&quot;], list = [&quot;String1&quot;] assert string. size()  == 6 assert array. size()  == 2 assert map. size()  == 1 assert list. size()  == 1
Gotchas ,[object Object]
is()  er sammenligning af objekt-referencer
return  behøves ikke. Retur er resultatet af sidste evaluererede udtryk.
Metoder og klasser er  public
Alle exceptions er unchecked og runtime!
Der er ingen primitiver – alt box'es
Decimal udregninger foregår i  BigDecimal
Metoder ,[object Object],def m(a, b = &quot;ukendt&quot;) {  println &quot;$a og $b&quot; } m('a') m('a','b') a og ukendt a og b
Metoder (2) ,[object Object],def metode() { [&quot;my string&quot;, 1] } def (string,value) = metode() assert string == &quot;my string&quot; assert value == 1
Groovy Closures ,[object Object]
Kan sendes med som parametre
Tænk: ”Annonymous Inner Classes” simplificeret!  def c = { a, b = &quot;ukendt&quot; -> println &quot;$a og $b&quot; } c('a','b') [key1:'value1',key2:'value2'].each(c) ['value1','value2'].each(c) c.call('1','2') Kommer i Java 8 (men hvornår)  Groovy har haft dem fra starten! a og b key1 og value1 key2 og value2 value1 og ukendt value2 og ukendt 1 og 2
Sandheden i Groovy ,[object Object]
Groovy boolean evaluering assert !null assert new Object() assert !&quot;&quot; assert &quot;Indhold&quot; assert ![]  // List assert [&quot;Indhold&quot;] Object o = null; assert(o == null); o = new Object(); assert(o != null); assert(&quot;&quot;.length() == 0); assert(&quot;Indhold&quot;.length() > 0); List l = new ArrayList(); assert(l.size() != null); l.add(&quot;Element&quot;); assert(l.size() > 0);
Syntaktisk sukker ,[object Object]
Elvis operator a?.b?.doSomething() if(getA() != null && getA().getB() != null) { getA().getB().doSomething(); } String x = b ?: ”default”  String x = getB() != null ? getB() : ”default”
Strings ,[object Object]
” Dette er en GString” ,[object Object],[object Object]
” Dette er en GString”.size()   // Længden på en streng
Multiline Strings def name = 'Nørder' println &quot;Hej $name&quot; def name=&quot;Nørder&quot; def xml = &quot;&quot;&quot;<xml> <element>Hej &quot;$name&quot;</element> </xml>&quot;&quot;&quot;

Weitere ähnliche Inhalte

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Groovy og Grails for Javaudviklere

  • 1. Groovy og Grails for Javaudviklere
  • 2.
  • 4.
  • 5.
  • 6. Stifter af GR8Conf – en konference for Groovy et al.
  • 7. Passioneret bruger af Groovy og Grails
  • 9.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Open Source (BSD / Apache licens)
  • 19. Inspireret af Python, Ruby og Smalltalk
  • 20. Flad indlæringkurve for Java-udviklere Java på Steroider!
  • 21.
  • 22. def i = 0 // Tildel integer i = ”streng” // skift til streng
  • 23. Et Java-eksempel public class UsingJava { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return &quot;Using Java &quot; + getName(); } public static void main(String[] args) { UsingJava usingJava = new UsingJava(); usingJava.setName(&quot;Geeks&quot;); System.out.println(usingJava); } }
  • 25. Et Java-eksempel Groovyfied class GettingGroovy { String name @Override String toString() { &quot;Get Groovy $name&quot; } } println new GettingGroovy(name: &quot;Geeks&quot;)
  • 26. public class HelloWorld { private String name; public String getName() { return name; } public void setName(String name) { this.name=name; } @Override public String toString() { return &quot;Hello &quot;+getName(); } public static void main(String[] args) { HelloWorld helloWorld = new HelloWorld(); helloWorld.setName(&quot;Geeks&quot;); System.out.println(helloWorld); } } Java vs. Groovy class GettingGroovy { String name String toString() { &quot;Get Groovy $name&quot; } } println new GettingGroovy(name: &quot;Geeks&quot;) Færre linier kode Færre mulighed for fejl! 18 linier kode 7 linier kode 60% mindre Kode!
  • 27.
  • 28. Groovy Lists def list = [ &quot;String 1&quot;,&quot;String 2&quot; ] assert list[0] == &quot;String 1&quot; assert list.get(0) == &quot;String 1&quot; assert list.size == 2 List list = Arrays.asList(&quot;String 1&quot;, &quot;String 2&quot;); assert(list.get(0).equals(&quot;String 1&quot;)); assert(list.size()==2);
  • 29.
  • 30. Groovy Maps def map = [key1:&quot;Value 1&quot;,key2: &quot;Value 2&quot;] assert !map.containsKey(&quot;key3&quot;) && !map[&quot;key3&quot;] && !map.key3 assert map.key1 assert map.key1==&quot;Value 1&quot; assert map.size() == 2 Map map = new HashMap(); map.put(&quot;Key 1&quot;,&quot;Value 1&quot;); map.put(&quot;Key 2&quot;,&quot;Value 2&quot;); assert(!map.containsKey(&quot;Key 3&quot;)); assert(map.containsKey(&quot;Key 1&quot;)); assert(map.get(&quot;Key 1&quot;).equals(&quot;Value 1&quot;)); assert(map.size() == 2);
  • 31.
  • 32.
  • 33. Med Groovy: public static void main(String[] args) { String string = &quot;String&quot;; String[] array = new String[] {&quot;String1&quot;,&quot;String2&quot;}; Map<String,String> map = new HashMap<String,String>(); map.put(&quot;Key1&quot;,&quot;Val1&quot;); List<String> list = new ArrayList<String>(); list.add(&quot;String1&quot;); assert string. length() ==6; assert array. length == 2; assert map. size() ==1; assert list. size() ==1; } def string = &quot;String&quot;, array = [&quot;String1&quot;,&quot;String2&quot;] def map = [Key1:&quot;Val1&quot;], list = [&quot;String1&quot;] assert string. size() == 6 assert array. size() == 2 assert map. size() == 1 assert list. size() == 1
  • 34.
  • 35. is() er sammenligning af objekt-referencer
  • 36. return behøves ikke. Retur er resultatet af sidste evaluererede udtryk.
  • 37. Metoder og klasser er public
  • 38. Alle exceptions er unchecked og runtime!
  • 39. Der er ingen primitiver – alt box'es
  • 41.
  • 42.
  • 43.
  • 44. Kan sendes med som parametre
  • 45. Tænk: ”Annonymous Inner Classes” simplificeret! def c = { a, b = &quot;ukendt&quot; -> println &quot;$a og $b&quot; } c('a','b') [key1:'value1',key2:'value2'].each(c) ['value1','value2'].each(c) c.call('1','2') Kommer i Java 8 (men hvornår) Groovy har haft dem fra starten! a og b key1 og value1 key2 og value2 value1 og ukendt value2 og ukendt 1 og 2
  • 46.
  • 47. Groovy boolean evaluering assert !null assert new Object() assert !&quot;&quot; assert &quot;Indhold&quot; assert ![] // List assert [&quot;Indhold&quot;] Object o = null; assert(o == null); o = new Object(); assert(o != null); assert(&quot;&quot;.length() == 0); assert(&quot;Indhold&quot;.length() > 0); List l = new ArrayList(); assert(l.size() != null); l.add(&quot;Element&quot;); assert(l.size() > 0);
  • 48.
  • 49. Elvis operator a?.b?.doSomething() if(getA() != null && getA().getB() != null) { getA().getB().doSomething(); } String x = b ?: ”default” String x = getB() != null ? getB() : ”default”
  • 50.
  • 51.
  • 52. ” Dette er en GString”.size() // Længden på en streng
  • 53. Multiline Strings def name = 'Nørder' println &quot;Hej $name&quot; def name=&quot;Nørder&quot; def xml = &quot;&quot;&quot;<xml> <element>Hej &quot;$name&quot;</element> </xml>&quot;&quot;&quot;
  • 54.
  • 55. Brugt meget i Groovys API'er
  • 56. Eksempel: String.metaClass.toCamelCase = { delegate.toLowerCase().replaceAll( /(_)([a-z0-9])/, { Object[] part -> part[2].toUpperCase() }) } String.metaClass.toSnakeCase = { capitalize = false -> def res = delegate.replaceAll( /([A-Z])/, /_$1/ ) .replaceAll( /^_/, '' ) capitalize ? res.toUpperCase() : res.toLowerCase() } println &quot;THIS_IS_A_CASE_FOR_THE_CAMEL&quot;.toCamelCase() println &quot;AndNowForSomeSnakeOil&quot;.toSnakeCase() println &quot;LoudYellingExample&quot;.toSnakeCase(true)
  • 57.
  • 58. Indlæs en url def path = '.', file = &quot;Groovy.txt&quot; println new File(path,file).text println new File(path,file).readLines().join(' ') new File(path,file).eachLine { line,i -> println &quot;${&quot;${i}&quot;.padLeft(2)}: ${line}&quot; } def url = &quot;http://oiorest.dk/danmark/kommuner/746/skoler&quot;.toURL() println url.text url.eachLine { line,i -> println &quot;${&quot;${i}&quot;.padLeft(3)}: ${line}&quot; }
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 68. @Lazy
  • 69.
  • 70.
  • 71.
  • 72. @Imutable (fortsat) @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Punter other = (Punter) obj; if (first == null) { if (other.first != null) return false; } else if (!first.equals(other.first)) return false; if (last == null) { if (other.last != null) return false; } else if (!last.equals(other.last)) return false; return true; } @Override public String toString() { return &quot;Punter(first:&quot; + first + &quot;, last:&quot; + last + &quot;)&quot;; } } @Immutable final class Punter { String first, last }
  • 73. Java og Groovy – en kærlighedshistorie Hvordan bruges Groovy og Java sammen DEMO!
  • 74.
  • 75. Testing vha. Spock (www.spockframework.org)
  • 76.
  • 77.
  • 78. class APublisher extends Specification { def &quot; send besked til alle subscribers &quot;() { setup: &quot; før kørsel skal der være en publisher og to subscribers &quot; def pub = new Publisher() def sub1 = Mock(Subscriber) def sub2 = Mock(Subscriber) pub.subscribers << sub1 << sub2 when: &quot; Når en publisher sender en besked &quot; pub.send(&quot;event&quot;) then: &quot; Skal hver receiver modtage den én gang &quot; 1 * sub1.receive(&quot;event&quot;) 1 * sub2.receive(&quot;event&quot;) } } Spock – fortæl en historie
  • 80. PAUSE! Hils på din sidemand Stræk benene Vi starter igen om 10 minutter.
  • 81. Web udvikling På den fede måde....
  • 82. Grails – en komplet stak + + +
  • 83.
  • 84. Kommandolinie værktøjet kan udføre de fleste kommandoer til Grails
  • 85. Unit og integrationstest er en naturlig del af udviklingsfasen
  • 86. Kan deployes til de fleste App-servere som en war fil
  • 87.
  • 88. Med Groovy elimineres det meste boilerplate kode
  • 89. Med mappings kan legacy systemer adresseres
  • 90. Har Event handlers til save/update/delete etc...
  • 91. Validering af data slår igennem i alle lag (model -> view)
  • 92. Basal CRUD def person = new Person(navn: 'Kurt', alder: 42) Person.save() def person = Person.get(1) assert person.id == 1 def person = Person.get(1) person.navn = 'Svend' person.save() def person = Person.get(1) person.delete() C R U D
  • 93. Dynamic finders def personer = Person.list() def personer = Person.list(sort: 'navn', order: 'desc') def personer = Person.findAllByNavnLike('%Jensen%') def person = Person.findByNavnLike('%Jensen%') def person = Person.findByNavnAndAlder('Svend', 42) def c = Konto.createCriteria() def konti = c.list { between(dato, igår, nu) ilike(navn, '%Jensen%') }
  • 94.
  • 95. Output af json og XML med få linier kode
  • 96. Web sider laves ud fra templates
  • 97. Det er meget nemt at lave urlMappings
  • 98. Forms og webflows – ingen problem.
  • 99. Interceptors og filters – super nemt!
  • 100. Grails – plugins 575 plugins http://www.wordle.net
  • 101. Grails
  • 102.
  • 103. Spock
  • 104. EasyB
  • 105. Griffon (Swing udvikling – der virker!)
  • 106. GMaven
  • 107. Gant
  • 108. GAELYK (Google App Engine møder Groovy)
  • 109. Se flere på http://groovy.codehaus.org
  • 111.
  • 117. Tak! Stil endelig spørgsmål!

Hinweis der Redaktion

  1. Husk: Fjern ”private” Lav et eksempel med void setName(name) { this.name = name.reverse() } Vis AST transformation
  2. Både enkelt-ping, dobbelt-ping og trippel-ping er en java.lang.String, men det øjeblik man bruger ${} bliver det til en Gstring Husk at forklare, size()
  3. Husk at forklare, at Groovy håndtere resourcer (open/close og fejl) automatisk.
  4. Vis indhold af http://oiorest.dk/danmark/kommuner/746/skoler I en browser!
  5. Vis indhold af http://oiorest.dk/danmark/kommuner/746/skoler I en browser!
  6. Vis del et af koden og vent med resten....
  7. Vis del to, hvor der testes mellem Groovy og Java
  8. Fortæl, at Spock er en DSL og er en yderligere udvidelse af Groovy, hvor man har lavet en syntaks som er specialiseret til at ”fortælle historier”
  9. Vis del tre, hvor der testes med Spock
  10. grails create-app Tieto cd Tieto grails run-app (Åben browser) grails create-domain-class dk.demo.Person nano grails-app/domain/dk/demo/Person String name int age grails create-controller dk.demo.Person nano grails-app/controller/dk/demo/Person static scaffold = true grails run-app grails install-plugin iwebkit grails install-iwebkit-templates grails run-app