Your SlideShare is downloading. ×
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Making Java Groovy
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Making Java Groovy

689

Published on

Speaker: Kenneth Kousen …

Speaker: Kenneth Kousen
Groovy isn't designed to replace Java -- it just makes Java cleaner and easier to develop. This presentation will look at various tasks Java developers need to do and demonstrate ways Groovy can help.
Topics will include building and testing applications, accessing both relational and NoSQL databases, working with web services, and more.

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
689
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Making Java Groovy Easier development with Groovy NFJS
  • 2. Contact Info Ken Kousen ken.kousen@kousenit.com @kenkousen Making Java Groovy http://manning.com/kousen
  • 3. Groovy JVM language compiler generates bytecodes
  • 4. Groovy Groovy Is Java OO language with similar syntax Everything is an object Strings and Groovy Strings
  • 5. Optional Typing Type is optional String, double, Employee, ... def x can be assigned to anything
  • 6. Duck Typing def x x.method() if method() exists at runtime, no problem
  • 7. Strings Single quotes == Java strings Double quotes == Groovy strings interpolation "Hello, ${name}!"
  • 8. POGOs Plain Old Groovy Objects getters / setters map-based constructor public / private
  • 9. Example Convert a POJO to a POGO JUnit test case (Java) POGO (Groovy)
  • 10. Groovy + Java Adding Groovy to Java is easy
  • 11. Groovy + Java Adding Java to Groovy is inevitable
  • 12. Operator Overloading Used extensively in Groovy JDK All operators correspond to methods
  • 13. Example java.math.BigDecimal Complex numbers (later)
  • 14. Collections Ranges 5..10 'a'..'z' now..then
  • 15. Collections Lists [3, 1, 4, 1, 5, 9] ['this', 'is', 'a', 'list']
  • 16. Collections Sets [3, 1, 4, 1, 5, 9] as Set Set strings
  • 17. Collections Maps def map = [a:1, b:2, c:3] map.d = 4 map['e'] = 5 map.put('f') = 6
  • 18. Groovy Groovy Is Not Java closures, builders, metaprogramming
  • 19. Closures { ... it ... } { x, y -> ... } function bodies as first class objects (oversimplified, but not a bad start...)
  • 20. Closures list.each { ... } iterator list.collect { ... } transform list by applying closure
  • 21. Example Closure Coercion { ... } as FilenameFilter No more anonymous inner classes
  • 22. Example RowMapper from Spring JdbcTemplate (Java) closure for mapRow (Groovy)
  • 23. Builders groovy.xml.MarkupBuilder groovy.json.JsonBuilder SwingBuilder, AntBuilder, ...
  • 24. Parsers and Slurpers XmlParser / XmlSlurper JsonSlurper
  • 25. Examples Google Geocoder lists, maps Groovy JDK collect groovy.util.XmlSlurper
  • 26. Examples ICNDB Groovy JDK JSON
  • 27. Metaprogramming Runtime metaprogramming Expando Expando MetaClass (EMC)
  • 28. Example Complex numbers metaprogramming Spock
  • 29. AST Transformations Compile time metaprogramming @Delegate @EqualsAndHashCode @Immutable
  • 30. Example SmartPhone @Delegate Phone @Delegate Camera
  • 31. Testing assert keyword returns nothing if true lots of debugging info if false
  • 32. Testing GroovyTestCase extends JUnit TestCase shouldFail(...) { ... }
  • 33. Testing Spock Framework
  • 34. Build Tool Gradle DSL for your build
  • 35. Only one
  • 36. Two (or more)
  • 37. Examples Groovy Vampires Groovy JDK REST (GET only) JSON Mongo DB
  • 38. Examples People service Full REST (w/o hypermedia) Spock POGOs AST Transformations groovy.sql.Sql
  • 39. Summary Groovy is Java Collections, Groovy JDK, Streamlined, simplified code Groovy is not Java Closures, Builders, Metaprogramming
  • 40. Thanks for coming! Please complete your session evals All code is (or will be) on GitHub https://github.com/kousen

×