Introducción a Groovy
-
Upload
j-juan-r-zuniga -
Category
Technology
-
view
1.854 -
download
0
description
Transcript of Introducción a Groovy
![Page 1: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/1.jpg)
@grailsmx
Groovy: el lenguaje dinámico para la JVM
José Juan R. Zuñiga
(@neodevelop)
![Page 2: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/2.jpg)
Agenda• Introducción abierta(Open Source y lenguajes de
desarrollo)• ¿Que es groovy?• Hola Mundo en Groovy• Azúcar Sintáctica• +Groovy en una mirada• Aplicaciones Desktop con Groovy• Acceso a base de datos con Groovy• Metaprogramación• Testing
![Page 3: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/3.jpg)
Introducción
![Page 4: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/4.jpg)
Groovy
![Page 5: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/5.jpg)
HolaMundo en Javapublic class HolaMundo { private String nombre; public String getNombre() { return nombre; } public void setNombre(String nombre) { this.nombre = nombre; } public String saluda() { return "Hola " + this.nombre + " !!!"; } public static void main(String[] args) { HolaMundo objeto = new HolaMundo(); objeto.setNombre("@grailsmx"); System.out.println(objeto.saluda()); }}
![Page 6: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/6.jpg)
HolaMundo en Groovypublic class HolaMundo { private String nombre; public String getNombre() { return nombre; } public void setNombre(String nombre) { this.nombre = nombre; } public String saluda() { return "Hola " + this.nombre + " !!!"; } public static void main(String[] args) { HolaMundo objeto = new HolaMundo(); objeto.setNombre("@grailsmx"); System.out.println(objeto.saluda()); }}
![Page 7: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/7.jpg)
Mejor a la manera Groovy
class HolaMundo { String nombre def saluda() { "Hola ${this.nombre} !!!" } }
def objeto = new HolaMundo(nombre:"@grailsmx")println(objeto.saluda())
![Page 8: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/8.jpg)
¿Cómo llegamos a esto…?• Tener el JDK instalado• Establecer la variable JAVA_HOME y agregarla al
PATH en el subdirectorio /bin• Descargamos la distribución de Groovy en http://
groovy.codehaus.org/• Creamos una variable de entorno GROOVY_HOME
apuntando al directorio donde se descomprimió la distribución
• Adicionalmente, incluir en el PATH el directorio /bin de la variable de entorno GROOVY_HOME, es decir: %GROOVY_HOME%/bin
• Let’s rock the code!!!
![Page 9: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/9.jpg)
+ Groovy en una mirada• Totalmente Orientado a objetos• Perfecta integración con Java• Closures• Convención de JavaBeans• Esencia vs. Ceremonia• Aritmética con BigDecimal por default para la operación
de punto flotante• API’s amigables y prácticas• XML, JDBC, JMX, Swing• DSL(Domain Specific Language)• Builders• Sobrecarga de operadores• GDK
![Page 10: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/10.jpg)
Azúcar sintáctica + GDK• Listas– def numeros = [1,2,3,4,5]
• Mapas– def mapa = [DF:'Distrito
Federal',MTY:'Monterrey']• Rangos– def rangos = 199..299
• Asignación Múltiple– def (a,b) = [10,20]
• Return Opcional– def metodo(bool) { if(bool) 1 else 0 }
![Page 11: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/11.jpg)
Groovy en profundidad• Meta-programación
– La habilidad de un lenguaje para modificarse a sí mismo• Transformaciones AST
– @Singleton– @Inmutable, @Lazy, @Delegate– @Newify– @Category & @Mixin– @PackageScope– @Bindable & @Vetoable– @Grab
![Page 12: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/12.jpg)
Aplicaciones Desktop
![Page 13: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/13.jpg)
Let’s code again!!!
![Page 14: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/14.jpg)
Base de Datos
![Page 15: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/15.jpg)
Metaprogramación
![Page 16: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/16.jpg)
Testing
![Page 17: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/17.jpg)
¿Quieres ser Groovy?
![Page 18: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/18.jpg)
@grailsmx
Aun hay algo más…
![Page 19: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/19.jpg)
@grailsmx
Esperen…
![Page 20: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/20.jpg)
• GULEV• @springhispano• @grailsmx
Agradecimiento
![Page 21: Introducción a Groovy](https://reader034.fdocuments.ec/reader034/viewer/2022052508/5598fb5d1a28ab63718b4654/html5/thumbnails/21.jpg)
@grailsmx
¿Preguntas?
…o comentarios…springhispano.org
grails.org.mx@neodevelop