SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Groovify your Java Code
A guide to Groovy syntax for Java coders
By for Coding Dojo 2014
Interactive slides at:
Hervé Vũ Roussel Agile Vietnam
https://slides.com/hroussel/groovify-your-java-code
Print / bracket, semicol optional
System.out.println("Hello World!");
println "Hello World!"
Return optional
String getCurrentCity() {
return "Ho Chi Minh City";
}
def getCurrentCity() {
"Ho Chi Minh City"
}
Try/catch optional
try{
Reader reader = new FileReader("/vietnam-cities.txt")
}
catch(FileNotFoundException e) {
e.printStackTrace()
}
def reader = new FileReader("/vietnam-cities.txt")
Duck typing
String s = "Hello";
String c = 'c';
Integer i = new Integer(1);
BigDecimal d = new BigDecimal(1.2);
def s = "Hello"
def c = 'c'
def i = 1
def d = 1.2
Strong typing
String s = "Hello";
Character = new Character(‘c’);
Integer i = new Integer(1);
Float d = new Float(1.2);
String s = "Hello"
Character c = 'c'
Integer i = 1
Float f = 1.2
Existential operator (Elvis)
if (city != null) {
if (city.getAirport() != null) {
city.getAirport().getCode();
}
}
city?.getAirport()?.getCode()
Truth
if (1 != 0)
if (new City() != null)
if ("John".equals(""))
if (["HCMC", "Hanoi"].length > 0)
if (1)
if (city)
if ("John")
if (["HCMC", "Hanoi"])
Collections
String [] cities = ["HCMC","Hanoi"];
System.out.println(cities[0]);
Map<String,String> airports = new HashMap<String,String>();
airports.put("SGN", "Ho Chi Minh City");
airports.put("CDG", "Paris");
System.out.println(airports.get("SGN"));
def cities = ["HCMC","Hanoi"]
println cities[0]
def airports = [SGN:"Ho Chi Minh City", CDG:"Paris"]
println airports.SGN
Ranges
List<String> alphabet = new ArrayList<String>();
for(int i=0;i<26;i++) {
alphabet.add(Character.toChars(i+97));
}
def alphabet = "a".."z"
GString
System.out.println("Hello " + user.name);
println "Hello ${user.name}"
Groovy Scripts
public class Script1 {
public static void main(String[] args){
String greeting = "Hello " + args[0];
System.out.println(greeting);
}
}
greeting = "Hello ${args[0]}"
println greeting
POGOs
public class City {
private String name;
public String getName() {
return this.name;
}
public String setName(String name) {
this.name = name;
}
}
System.out.println(new City("HCMC").getName());
class City {
String name
}
println new City(name: "HCMC").name
Compare objects
a.equals(b);
a.compareTo(b);
a == b
a < b
Default parameters
public class Trip {
public Trip(String source, String dest, String type) {
if (type == null)
this.type = "Car";
}
}
new Trip("HCMC", "Vung Tau", null);
class Trip {
Trip(String source, String dest, String type = "Car") {
this.type = type;
}
}
new Trip("HCMC", "Vung Tau")
Closures
List result = new ArrayList();
for(city in city) {
if (city.startsWith("H")
result.add(city)
}
cities.findAll { it.startsWith("H") }
Closures (cont.)
​class City {
String name
}
def cities = [
new City(name: "Mui Ne"),
new City(name: "Hanoi")
]
cities.collect { it.name + ", VN" } ==
[ "Mui Ne, VN", "Hanoi, VN" ]
cities.any { it.name.indexOf(" ") != -1 } == true
cities.every { it.name.indexOf(" ") == -1 } == false
cities.find { it.name.startsWith("H") }.name == "Hanoi"
The End
More on Groovy:
Book: (I didn't write it!)
Slides:
Interactive:
PDF:
Thank you!
Free: Groovy User Guide
Groovy Recipes: Greasing the Wheels of Java
Online compiler/runner
http://slides.com/hroussel
https://www.slideshare.net/hroussel
Hervé Vũ Roussel
http://herveroussel.com
Groovify your Java CodeA guide to Groovy syntax for Java coders By Hervé Vũ Roussel for Agile
Vietnam Coding Dojo 2014 Interactive slides at: https://slides.com/hroussel/groovify-your-java-code
Groovify your Java code
Edit deck title & description
a day ago 0 68
Hervé Roussel
http://www.herveroussel.com hvroussel
0
Tweet 0
0
Like
We were unable to load Disqus. If you are a moderator please see our troubleshooting guide
0 Comments Slides
Disqus
Faceb
Twitte
Googl
Login
Newest
Oldest
Sort by Best
Best
Share
Share this discussion on
Start the discussion…

Contenu connexe

Tendances (20)

block introduce
block introduceblock introduce
block introduce
 
Groovyノススメ
GroovyノススメGroovyノススメ
Groovyノススメ
 
Hotel Management In C++
Hotel Management In C++Hotel Management In C++
Hotel Management In C++
 
ClojureScript - A functional Lisp for the browser
ClojureScript - A functional Lisp for the browserClojureScript - A functional Lisp for the browser
ClojureScript - A functional Lisp for the browser
 
Go for Rubyists
Go for RubyistsGo for Rubyists
Go for Rubyists
 
Code
CodeCode
Code
 
Tools.cpp
Tools.cppTools.cpp
Tools.cpp
 
1
11
1
 
Functional Reactive Programming
Functional Reactive ProgrammingFunctional Reactive Programming
Functional Reactive Programming
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
Java8 and Functional Programming
Java8 and Functional ProgrammingJava8 and Functional Programming
Java8 and Functional Programming
 
C++ programs
C++ programsC++ programs
C++ programs
 
C++ tutorial
C++ tutorialC++ tutorial
C++ tutorial
 
C++totural file
C++totural fileC++totural file
C++totural file
 
Tugas Program C++
Tugas Program C++Tugas Program C++
Tugas Program C++
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
Functional programming with Immutable .JS
Functional programming with Immutable .JSFunctional programming with Immutable .JS
Functional programming with Immutable .JS
 
Do while loop
Do while loopDo while loop
Do while loop
 
completion_proc and history
completion_proc and historycompletion_proc and history
completion_proc and history
 
Conversion of data types in java
Conversion of data types in javaConversion of data types in java
Conversion of data types in java
 

En vedette

Code fast & Break things with Jenkins & Continuous Integration
Code fast & Break things with Jenkins & Continuous IntegrationCode fast & Break things with Jenkins & Continuous Integration
Code fast & Break things with Jenkins & Continuous IntegrationHervé Vũ Roussel
 
Pelican Cays 2003 To 2007 Paradise Cove
Pelican Cays 2003 To 2007 Paradise CovePelican Cays 2003 To 2007 Paradise Cove
Pelican Cays 2003 To 2007 Paradise Covekennedykiwi
 
Old Guard Presentation
Old Guard PresentationOld Guard Presentation
Old Guard PresentationBobby.Lindsey
 
3 lessons i learned from building a killer start up
3 lessons i learned from building a killer start up3 lessons i learned from building a killer start up
3 lessons i learned from building a killer start upHervé Vũ Roussel
 
How I learned to stop worrying and love the bugs with Jenkins & Continuous In...
How I learned to stop worrying and love the bugs with Jenkins & Continuous In...How I learned to stop worrying and love the bugs with Jenkins & Continuous In...
How I learned to stop worrying and love the bugs with Jenkins & Continuous In...Hervé Vũ Roussel
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Hervé Vũ Roussel
 
หนังสือ Yii Framework Application Workshop เล่ม 1
หนังสือ Yii Framework Application Workshop เล่ม 1หนังสือ Yii Framework Application Workshop เล่ม 1
หนังสือ Yii Framework Application Workshop เล่ม 1Manop Kongoon
 
หนังสือ Yii framework 2 Web Application Basic ฉบับพื้นฐาน
หนังสือ Yii framework 2 Web Application Basic ฉบับพื้นฐานหนังสือ Yii framework 2 Web Application Basic ฉบับพื้นฐาน
หนังสือ Yii framework 2 Web Application Basic ฉบับพื้นฐานManop Kongoon
 
หนังสือ Yii framework Tip 50 เทคนิค Yii Framework
หนังสือ Yii framework Tip 50 เทคนิค Yii Frameworkหนังสือ Yii framework Tip 50 เทคนิค Yii Framework
หนังสือ Yii framework Tip 50 เทคนิค Yii FrameworkManop Kongoon
 
Yii framework 2 basic training
Yii framework 2 basic trainingYii framework 2 basic training
Yii framework 2 basic trainingManop Kongoon
 
HTML PHP MySQL สำหรับเว็บโปรแกรมเมอร์มือใหม่
HTML PHP MySQL สำหรับเว็บโปรแกรมเมอร์มือใหม่HTML PHP MySQL สำหรับเว็บโปรแกรมเมอร์มือใหม่
HTML PHP MySQL สำหรับเว็บโปรแกรมเมอร์มือใหม่Manop Kongoon
 
The Climate Challenge: Saving Ourselves
The Climate Challenge: Saving OurselvesThe Climate Challenge: Saving Ourselves
The Climate Challenge: Saving OurselvesSustento
 
Envisaging the future
Envisaging the futureEnvisaging the future
Envisaging the futureSustento
 
Developing a resilient money system
Developing a resilient money systemDeveloping a resilient money system
Developing a resilient money systemSustento
 
Defusing the debt bomb talk
Defusing the debt bomb talk Defusing the debt bomb talk
Defusing the debt bomb talk Sustento
 
Human Capital as 21st Century Infrastructure
Human Capital as 21st Century Infrastructure Human Capital as 21st Century Infrastructure
Human Capital as 21st Century Infrastructure Sustento
 

En vedette (20)

Code fast & Break things with Jenkins & Continuous Integration
Code fast & Break things with Jenkins & Continuous IntegrationCode fast & Break things with Jenkins & Continuous Integration
Code fast & Break things with Jenkins & Continuous Integration
 
Pelican Cays 2003 To 2007 Paradise Cove
Pelican Cays 2003 To 2007 Paradise CovePelican Cays 2003 To 2007 Paradise Cove
Pelican Cays 2003 To 2007 Paradise Cove
 
Old Guard Presentation
Old Guard PresentationOld Guard Presentation
Old Guard Presentation
 
Offline First with CouchDB
Offline First with CouchDBOffline First with CouchDB
Offline First with CouchDB
 
GW SDAB Dev Tools 2012
GW SDAB Dev Tools 2012GW SDAB Dev Tools 2012
GW SDAB Dev Tools 2012
 
3 lessons i learned from building a killer start up
3 lessons i learned from building a killer start up3 lessons i learned from building a killer start up
3 lessons i learned from building a killer start up
 
How I learned to stop worrying and love the bugs with Jenkins & Continuous In...
How I learned to stop worrying and love the bugs with Jenkins & Continuous In...How I learned to stop worrying and love the bugs with Jenkins & Continuous In...
How I learned to stop worrying and love the bugs with Jenkins & Continuous In...
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS
 
หนังสือ Yii Framework Application Workshop เล่ม 1
หนังสือ Yii Framework Application Workshop เล่ม 1หนังสือ Yii Framework Application Workshop เล่ม 1
หนังสือ Yii Framework Application Workshop เล่ม 1
 
หนังสือ Yii framework 2 Web Application Basic ฉบับพื้นฐาน
หนังสือ Yii framework 2 Web Application Basic ฉบับพื้นฐานหนังสือ Yii framework 2 Web Application Basic ฉบับพื้นฐาน
หนังสือ Yii framework 2 Web Application Basic ฉบับพื้นฐาน
 
หนังสือ Yii framework Tip 50 เทคนิค Yii Framework
หนังสือ Yii framework Tip 50 เทคนิค Yii Frameworkหนังสือ Yii framework Tip 50 เทคนิค Yii Framework
หนังสือ Yii framework Tip 50 เทคนิค Yii Framework
 
Yii framework 2 basic training
Yii framework 2 basic trainingYii framework 2 basic training
Yii framework 2 basic training
 
HTML PHP MySQL สำหรับเว็บโปรแกรมเมอร์มือใหม่
HTML PHP MySQL สำหรับเว็บโปรแกรมเมอร์มือใหม่HTML PHP MySQL สำหรับเว็บโปรแกรมเมอร์มือใหม่
HTML PHP MySQL สำหรับเว็บโปรแกรมเมอร์มือใหม่
 
The Climate Challenge: Saving Ourselves
The Climate Challenge: Saving OurselvesThe Climate Challenge: Saving Ourselves
The Climate Challenge: Saving Ourselves
 
Sierra Club Pro
Sierra Club ProSierra Club Pro
Sierra Club Pro
 
Envisaging the future
Envisaging the futureEnvisaging the future
Envisaging the future
 
Portfolio Slides
Portfolio SlidesPortfolio Slides
Portfolio Slides
 
Developing a resilient money system
Developing a resilient money systemDeveloping a resilient money system
Developing a resilient money system
 
Defusing the debt bomb talk
Defusing the debt bomb talk Defusing the debt bomb talk
Defusing the debt bomb talk
 
Human Capital as 21st Century Infrastructure
Human Capital as 21st Century Infrastructure Human Capital as 21st Century Infrastructure
Human Capital as 21st Century Infrastructure
 

Similaire à Groovify your java code by hervé roussel

Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my dayTor Ivry
 
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistJEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistAnton Arhipov
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervosoLuis Vendrame
 
JavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with JavassistJavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with JavassistAnton Arhipov
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)ThomasHorta
 
Productive Programming in Groovy
Productive Programming in GroovyProductive Programming in Groovy
Productive Programming in GroovyGanesh Samarthyam
 
Speed up the mobile development process
Speed up the mobile development processSpeed up the mobile development process
Speed up the mobile development processLeonardoSarra
 
Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Chang W. Doh
 
Riga Dev Day 2016 - Having fun with Javassist
Riga Dev Day 2016 - Having fun with JavassistRiga Dev Day 2016 - Having fun with Javassist
Riga Dev Day 2016 - Having fun with JavassistAnton Arhipov
 
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksiiOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksiMarin Benčević
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsTypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsAlfonso Peletier
 
Kotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsKotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsJigar Gosar
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agentsRafael Winterhalter
 

Similaire à Groovify your java code by hervé roussel (20)

Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
 
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistJEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with Javassist
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
JavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with JavassistJavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with Javassist
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)
 
Productive Programming in Groovy
Productive Programming in GroovyProductive Programming in Groovy
Productive Programming in Groovy
 
Speed up the mobile development process
Speed up the mobile development processSpeed up the mobile development process
Speed up the mobile development process
 
Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요
 
Riga Dev Day 2016 - Having fun with Javassist
Riga Dev Day 2016 - Having fun with JavassistRiga Dev Day 2016 - Having fun with Javassist
Riga Dev Day 2016 - Having fun with Javassist
 
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksiiOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsTypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
 
What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7
 
Java and j2ee_lab-manual
Java and j2ee_lab-manualJava and j2ee_lab-manual
Java and j2ee_lab-manual
 
Kotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsKotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrains
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agents
 
P2
P2P2
P2
 

Dernier

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Dernier (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Groovify your java code by hervé roussel

  • 1. Groovify your Java Code A guide to Groovy syntax for Java coders By for Coding Dojo 2014 Interactive slides at: Hervé Vũ Roussel Agile Vietnam https://slides.com/hroussel/groovify-your-java-code
  • 2. Print / bracket, semicol optional System.out.println("Hello World!"); println "Hello World!"
  • 3. Return optional String getCurrentCity() { return "Ho Chi Minh City"; } def getCurrentCity() { "Ho Chi Minh City" }
  • 4. Try/catch optional try{ Reader reader = new FileReader("/vietnam-cities.txt") } catch(FileNotFoundException e) { e.printStackTrace() } def reader = new FileReader("/vietnam-cities.txt")
  • 5. Duck typing String s = "Hello"; String c = 'c'; Integer i = new Integer(1); BigDecimal d = new BigDecimal(1.2); def s = "Hello" def c = 'c' def i = 1 def d = 1.2
  • 6. Strong typing String s = "Hello"; Character = new Character(‘c’); Integer i = new Integer(1); Float d = new Float(1.2); String s = "Hello" Character c = 'c' Integer i = 1 Float f = 1.2
  • 7. Existential operator (Elvis) if (city != null) { if (city.getAirport() != null) { city.getAirport().getCode(); } } city?.getAirport()?.getCode()
  • 8. Truth if (1 != 0) if (new City() != null) if ("John".equals("")) if (["HCMC", "Hanoi"].length > 0) if (1) if (city) if ("John") if (["HCMC", "Hanoi"])
  • 9. Collections String [] cities = ["HCMC","Hanoi"]; System.out.println(cities[0]); Map<String,String> airports = new HashMap<String,String>(); airports.put("SGN", "Ho Chi Minh City"); airports.put("CDG", "Paris"); System.out.println(airports.get("SGN")); def cities = ["HCMC","Hanoi"] println cities[0] def airports = [SGN:"Ho Chi Minh City", CDG:"Paris"] println airports.SGN
  • 10. Ranges List<String> alphabet = new ArrayList<String>(); for(int i=0;i<26;i++) { alphabet.add(Character.toChars(i+97)); } def alphabet = "a".."z"
  • 11. GString System.out.println("Hello " + user.name); println "Hello ${user.name}"
  • 12. Groovy Scripts public class Script1 { public static void main(String[] args){ String greeting = "Hello " + args[0]; System.out.println(greeting); } } greeting = "Hello ${args[0]}" println greeting
  • 13. POGOs public class City { private String name; public String getName() { return this.name; } public String setName(String name) { this.name = name; } } System.out.println(new City("HCMC").getName()); class City { String name } println new City(name: "HCMC").name
  • 15. Default parameters public class Trip { public Trip(String source, String dest, String type) { if (type == null) this.type = "Car"; } } new Trip("HCMC", "Vung Tau", null); class Trip { Trip(String source, String dest, String type = "Car") { this.type = type; } } new Trip("HCMC", "Vung Tau")
  • 16. Closures List result = new ArrayList(); for(city in city) { if (city.startsWith("H") result.add(city) } cities.findAll { it.startsWith("H") }
  • 17. Closures (cont.) ​class City { String name } def cities = [ new City(name: "Mui Ne"), new City(name: "Hanoi") ] cities.collect { it.name + ", VN" } == [ "Mui Ne, VN", "Hanoi, VN" ] cities.any { it.name.indexOf(" ") != -1 } == true cities.every { it.name.indexOf(" ") == -1 } == false cities.find { it.name.startsWith("H") }.name == "Hanoi"
  • 18.
  • 19. The End More on Groovy: Book: (I didn't write it!) Slides: Interactive: PDF: Thank you! Free: Groovy User Guide Groovy Recipes: Greasing the Wheels of Java Online compiler/runner http://slides.com/hroussel https://www.slideshare.net/hroussel Hervé Vũ Roussel http://herveroussel.com
  • 20. Groovify your Java CodeA guide to Groovy syntax for Java coders By Hervé Vũ Roussel for Agile Vietnam Coding Dojo 2014 Interactive slides at: https://slides.com/hroussel/groovify-your-java-code Groovify your Java code Edit deck title & description a day ago 0 68 Hervé Roussel http://www.herveroussel.com hvroussel 0 Tweet 0 0 Like We were unable to load Disqus. If you are a moderator please see our troubleshooting guide 0 Comments Slides Disqus Faceb Twitte Googl Login Newest Oldest Sort by Best Best Share Share this discussion on Start the discussion…