0
Groovy and Grails introduction A pragmatic view Miguel Ángel Pastor Olivar miguelinlas3 at gmail dot com http://miguelinla...
Spring Jetty Database Eclipse Web Architecture Java IntelliJ DSL's Software Patterns Maven Groovy Tomcat Unit Testing Byte...
Java Platform
Java Platform <ul><li>Java is a platform, not a language
Interprets bytecode (.class files)
Multiple platform support (Linux, OSx,...)
Garbage collection
Java Language
. . . </li></ul>
Java Platform <ul><li>JSR 924: Virtual Machine Specification
JSR 901: Java Language Specification
JSR 241: Groovy Language Specification
JSR 274: Bean Shell Scripting Language
JSR 292:  Supporting Dynamically Typed Languages (JavaScript,Scala,Python, . . .) </li></ul>
Java Platform <ul><li>DaVinci Machine: OpenJDK subproject
Multiple Language support (especially dynamic)
JVM Extensions
Co-existing with Java
Common base model (garbage collection, model execution, . . . ) </li></ul>
Groovy Features
Groovy <ul><li>Dynamic Language for the JVM
Additional power features like Python, Ruby and Smalltalk
Modern programming features to Java developers
DSLs: easy to read and maintain
Writing shell and build script easy (Ant DSL,OO) </li></ul>
Groovy <ul><li>Strong typing (optional)
Duck typing
Java Object Model
Closures: High Order Functions
Easy Java Integration
Similar to Java syntax </li></ul>
Installing Groovy <ul><li>Download latest release:  download
Set environment variable GROOVY_HOME
Add GROOVY_HOMEin to the path
Open a console and type:  groovy -v
Ready to work! </li></ul>
Groovy Datatypes <ul><li>Everything is a object
Upcoming SlideShare
Loading in...5
×

Groovy and Grails intro

2,990

Published on

A sample introduction to Groovy and Grails. It´s not finished yet.

Published in: Technology

Transcript of "Groovy and Grails intro"

  1. 1. Groovy and Grails introduction A pragmatic view Miguel Ángel Pastor Olivar miguelinlas3 at gmail dot com http://miguelinlas3.blogspot.com http://twitter.com/miguelinlas3
  2. 2. Spring Jetty Database Eclipse Web Architecture Java IntelliJ DSL's Software Patterns Maven Groovy Tomcat Unit Testing ByteCode Agile Netbeans Dynamic Languages Domain Design Dependency Injection Grails Sitemesh Hibernate Plugin Architecture
  3. 3. Java Platform
  4. 4. Java Platform <ul><li>Java is a platform, not a language
  5. 5. Interprets bytecode (.class files)
  6. 6. Multiple platform support (Linux, OSx,...)
  7. 7. Garbage collection
  8. 8. Java Language
  9. 9. . . . </li></ul>
  10. 10. Java Platform <ul><li>JSR 924: Virtual Machine Specification
  11. 11. JSR 901: Java Language Specification
  12. 12. JSR 241: Groovy Language Specification
  13. 13. JSR 274: Bean Shell Scripting Language
  14. 14. JSR 292: Supporting Dynamically Typed Languages (JavaScript,Scala,Python, . . .) </li></ul>
  15. 15. Java Platform <ul><li>DaVinci Machine: OpenJDK subproject
  16. 16. Multiple Language support (especially dynamic)
  17. 17. JVM Extensions
  18. 18. Co-existing with Java
  19. 19. Common base model (garbage collection, model execution, . . . ) </li></ul>
  20. 20. Groovy Features
  21. 21. Groovy <ul><li>Dynamic Language for the JVM
  22. 22. Additional power features like Python, Ruby and Smalltalk
  23. 23. Modern programming features to Java developers
  24. 24. DSLs: easy to read and maintain
  25. 25. Writing shell and build script easy (Ant DSL,OO) </li></ul>
  26. 26. Groovy <ul><li>Strong typing (optional)
  27. 27. Duck typing
  28. 28. Java Object Model
  29. 29. Closures: High Order Functions
  30. 30. Easy Java Integration
  31. 31. Similar to Java syntax </li></ul>
  32. 32. Installing Groovy <ul><li>Download latest release: download
  33. 33. Set environment variable GROOVY_HOME
  34. 34. Add GROOVY_HOMEin to the path
  35. 35. Open a console and type: groovy -v
  36. 36. Ready to work! </li></ul>
  37. 37. Groovy Datatypes <ul><li>Everything is a object
  38. 38. Optional typing
  39. 39. Overriding operators
  40. 40. Working with strings
  41. 41. Working with regular expressions
  42. 42. Working with numbers </li></ul>
  43. 43. Groovy Collections <ul><li>Working with ranges
  44. 44. Working with lists
  45. 45. Working with maps
  46. 46. Concurrent modifications </li></ul>
  47. 47. Working with closures <ul><li>Piece of code wrapped up as an object
  48. 48. Syntax: code in curly braces
  49. 49. Assign it to a variable
  50. 50. Using methods as closures </li><ul><ul><ul><ul><li>reference.&someMethod </li></ul></ul></ul></ul><li>Calling them explicitly
  51. 51. Return from closures </li></ul>
  52. 52. Control Structures <ul><li>Working with if-else
  53. 53. Working with switch
  54. 54. Working with while
  55. 55. Iterating over closures
  56. 56. Return values from if/else
  57. 57. Return values from exception handlers </li></ul>
  58. 58. Object Orientation <ul><li>Similar to Java Model
  59. 59. Methods and fields: modifiers are not needed
  60. 60. Positional and named parameters
  61. 61. Dynamics: </li><ul><ul><ul><ul><ul><ul><li>ObjReference.'method-name' </li></ul></ul></ul></ul></ul></ul><li>Coercion with as operator
  62. 62. Coercion in assignment
  63. 63. Type aliasing </li></ul>
  64. 64. Database programming <ul><li>SQL easier
  65. 65. SQL more Groovy
  66. 66. Performing read queries
  67. 67. Performing write queries
  68. 68. A practical example </li></ul>
  69. 69. Working with builders <ul><li>Domain Specific Languages hype
  70. 70. Easy to read and maintain
  71. 71. Building DSL: outside the limits
  72. 72. Using DSL: building RCP apps </li></ul>
  73. 73. References <ul><li>http://groovy.codehaus.org/Documentation
  74. 74. Groovy in Action ( Second Edition Early Access )
  75. 75. Programming Groovy
  76. 76. Neo Metrics products: AquaBM, UserMgmt
  77. 77. Surf the web! </li></ul>
  78. 78. Grails Features
  79. 79. Motivations and pros <ul><li>Unnecessary complexity (DRY)
  80. 80. Grails,Rails,Django, TurboGears
  81. 81. Reduce complexity
  82. 82. Built on top proven technologies
  83. 83. Full stack development
  84. 84. SpringSource </li></ul>
  85. 85. Architecture (I) <ul><li>ORM built on Hibernate
  86. 86. Views technologies: Groovy Server Pages
  87. 87. Controller layer built on Spring MVC
  88. 88. Command layer based on Gant
  89. 89. Embedded Tomcat (and Jetty). Fly reloading
  90. 90. Depedency Injection based on Spring
  91. 91. Support for internazionalitation </li></ul>
  92. 92. Architecture (II) <ul><li>Transactional service layer (Spring´s transactions)
  93. 93. Groovy power
  94. 94. Extensive use of Domain Specific Languages
  95. 95. Plugins architecture </li></ul>
  96. 96. Installing Grails <ul><li>Download latest release: download
  97. 97. Set environment variable GRAILS_HOME
  98. 98. Add GRAILS_HOMEin to the path
  99. 99. Open a console and type: grails help
  100. 100. Ready to work! </li></ul>
  101. 101. Beginning Grails <ul><li>Our first Grails application
  102. 102. Setting up an IDE: Spring Tool Suite
  103. 103. Convention over configuration </li></ul>
  104. 104. Beginning Grails <ul><li>Running application: grails run-app
  105. 105. Testing application: grails test-app
  106. 106. Deploying application: grails war
  107. 107. Servlet 2.4+ container </li></ul>
  108. 108. GORM (I) <ul><li>Creating domain class: grails create-domain-class
  109. 109. Create operation
  110. 110. Read operation
  111. 111. Update operation
  112. 112. Delete operation </li></ul>
  113. 113. GORM (II) <ul><li>Domain modeling: POGO
  114. 114. Asocciation: one to one
  115. 115. Association: one to many
  116. 116. Association: many to many
  117. 117. Inheritance
  118. 118. Performance tips
  119. 119. Cascading updates and deletes </li></ul>
  120. 120. GORM (III) <ul><li>Basics querying: List, retrieve by id
  121. 121. Dynamic finders: findBy, findByAll
  122. 122. Method expressions: findBy([Property][Comparator][Boolean Operator])?[Property][Comparator]
  123. 123. Criteria: building complex queries
  124. 124. Programmatic transactions: withTransaction </li></ul>
  125. 125. Controllers (I) <ul><li>Handling requests, preparing responses
  126. 126. Class *Controller in grails-app/controllers
  127. 127. Each closure maps to a URI
  128. 128. Available scopes </li><ul><ul><ul><li>ServletContext
  129. 129. Session
  130. 130. Request
  131. 131. Params
  132. 132. Flash </li></ul></ul></ul></ul>
  133. 133. Controllers (II) <ul><li>Model and View: a model is a map
  134. 134. Explicit model return or controller properties
  135. 135. Rendering views: grails-app/views/controller/actionName.gsp
  136. 136. Use of render. Rendering xml, json
  137. 137. More concepts: interceptors, filters </li></ul>
  138. 138. Groovy Server Pages (I) <ul><li>View technology: similar to JSP or ASP
  139. 139. HTML + tags
  140. 140. <% %> embed code (discouraged!!)
  141. 141. Prefedined variables </li><ul><ul><ul><li>Application
  142. 142. ApplicationContext
  143. 143. Flash
  144. 144. GrailsApplication
  145. 145. Out, params, request, response, session webrequest </li></ul></ul></ul></ul>
  146. 146. Groovy Server Pages (II) <ul><li>Page directives: import classes
  147. 147. Views and templates.
  148. 148. GSP Builting Tags: <g:XXX> </li><ul><ul><ul><ul><li>Logic and iteration
  149. 149. Search and filtering
  150. 150. Links and resources
  151. 151. Form and fields </li></ul></ul></ul></ul></ul>
  152. 152. The service layer (I) <ul><li>Not embed application logic in controllers
  153. 153. New service: grails create-service
  154. 154. Transacional by default: static transactional = false
  155. 155. Depedency injection by convention
  156. 156. Reusable logic
  157. 157. Use from Java classes </li></ul>
  158. 158. References <ul><li>http://grails.org/doc/latest/
  159. 159. Grails in action: http://www.manning.com/gsmith/
  160. 160. The Definitive Guide to Grails, Second Edition
  161. 161. http://www.grailstutorials.com/home/ </li></ul>
  162. 162. Real examples
  163. 163. Some real examples <ul><li>Cronos: sample management app
  164. 164. Doing REST in Grails </li></ul>
  165. 165. Thank you very much all for coming!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×