SlideShare a Scribd company logo
1 of 13
SPRINGONE2GX
WASHINGTON, DC
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attributio n-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Becoming an Advanced Groovy
Developer
By Tom Henricksen
@tomhenricksen
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Agenda
• Design Patterns
• Mixing Java and Groovy
• Calling other languages
2
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Design Patterns
What are Design Patterns?
Types
• Structural
• Creational
• Behavioral
3
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Design Patterns
• Why Design Patterns?
• Good Communication tools
• Don’t force in
4
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Design Patterns
Iterator pattern
• Behavioral
• Traverse collections
5
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Iterator Pattern
6
// Iterator example – for in
for (item in container) { println item }
// Iterator example – eachWithIndex
colors.eachWithIndex{ item, pos ->
printlin “Position $pos contains ‘$item’”
}
// Iterator example – each
(1..3).each {
println “Number ${it}”
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Design Patterns
Adapter Pattern
• Structural
• Wrap functionality
7
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Adaptor Pattern
8
// Adapter example
class SquarePegAdapter {
def peg
def getRadius() {
Math.sqrt(((peg.width / 2) * * 2) * 2)
}
String toString() {
“SquarePegAdapter with peg $peg.width and radius $radius”
}
}
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Design Patterns
Decorator Pattern
• Structural
• Add behavior
9
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Decorator Pattern
10
// Decorator example
class UpperLogger extends Logger {
private Logger logger
UpperLogger(logger) {
this.logger = logger
}
def log(String message) {
logger.log(message.toUpperCase())
}
}
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Design Patterns
Singleton Pattern
• Creational
• Ensure only one
11
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Singleton Pattern
12
// Decorator example
class VoteCollector {
def votes = 0
private static final INSTANCE = new VoteCollector()
static getInstance() { return INSTANCE }
private VoteCollector() { }
def display() { println "Collector:${hashCode()}, Votes:$votes" }
}
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Groovy Design Patterns
Questions
• What design pattern would you add?
13

More Related Content

Similar to Becoming an Advanced Groovy Developer Spring One 2gx 2015

What's new in Spring Boot 2.0
What's new in Spring Boot 2.0What's new in Spring Boot 2.0
What's new in Spring Boot 2.0VMware Tanzu
 
riffing on Knative - Scott Andrews
riffing on Knative - Scott Andrewsriffing on Knative - Scott Andrews
riffing on Knative - Scott AndrewsVMware Tanzu
 
Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Daniel Woods
 
Grooscript in Action SpringOne2gx 2015
Grooscript in Action SpringOne2gx 2015Grooscript in Action SpringOne2gx 2015
Grooscript in Action SpringOne2gx 2015Jorge Franco Leza
 
Data Migration at Scale with RabbitMQ and Spring Integration
Data Migration at Scale with RabbitMQ and Spring IntegrationData Migration at Scale with RabbitMQ and Spring Integration
Data Migration at Scale with RabbitMQ and Spring IntegrationAlvaro Videla
 
Square Pegs, Square Holes: CI/CD That Fits
Square Pegs, Square Holes: CI/CD That FitsSquare Pegs, Square Holes: CI/CD That Fits
Square Pegs, Square Holes: CI/CD That FitsVMware Tanzu
 
State of Securing Restful APIs s12gx2015
State of Securing Restful APIs s12gx2015State of Securing Restful APIs s12gx2015
State of Securing Restful APIs s12gx2015robwinch
 
Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs VMware Tanzu
 
Fast 5 Things You Can Do Now to Get Ready for the Cloud
Fast 5 Things You Can Do Now to Get Ready for the CloudFast 5 Things You Can Do Now to Get Ready for the Cloud
Fast 5 Things You Can Do Now to Get Ready for the CloudVMware Tanzu
 
Teaching TDD to Different Learning Styles
Teaching TDD to Different Learning StylesTeaching TDD to Different Learning Styles
Teaching TDD to Different Learning StylesVMware Tanzu
 
Intro to Reactive Programming
Intro to Reactive ProgrammingIntro to Reactive Programming
Intro to Reactive ProgrammingStéphane Maldini
 
Intro To Reactive Programming
Intro To Reactive ProgrammingIntro To Reactive Programming
Intro To Reactive ProgrammingRossen Stoyanchev
 
Marcin Grzejszczak - Contract Tests in the Enterprise
Marcin Grzejszczak - Contract Tests in the EnterpriseMarcin Grzejszczak - Contract Tests in the Enterprise
Marcin Grzejszczak - Contract Tests in the EnterpriseSegFaultConf
 
Spring MVC 4.2: New and Noteworthy
Spring MVC 4.2: New and NoteworthySpring MVC 4.2: New and Noteworthy
Spring MVC 4.2: New and NoteworthyRossen Stoyanchev
 
The Beginner’s Guide To Spring Cloud
The Beginner’s Guide To Spring CloudThe Beginner’s Guide To Spring Cloud
The Beginner’s Guide To Spring CloudVMware Tanzu
 
Accelerating the Developers' Road to the Cloud at Enterprise Scale
Accelerating the Developers' Road to the Cloud at Enterprise ScaleAccelerating the Developers' Road to the Cloud at Enterprise Scale
Accelerating the Developers' Road to the Cloud at Enterprise ScaleVMware Tanzu
 
Spring Tools 4 - Eclipse and Beyond
Spring Tools 4 - Eclipse and BeyondSpring Tools 4 - Eclipse and Beyond
Spring Tools 4 - Eclipse and BeyondVMware Tanzu
 
Enable Authentication and Authorization with Azure Active Directory and Sprin...
Enable Authentication and Authorization with Azure Active Directory and Sprin...Enable Authentication and Authorization with Azure Active Directory and Sprin...
Enable Authentication and Authorization with Azure Active Directory and Sprin...VMware Tanzu
 

Similar to Becoming an Advanced Groovy Developer Spring One 2gx 2015 (20)

What's new in Spring Boot 2.0
What's new in Spring Boot 2.0What's new in Spring Boot 2.0
What's new in Spring Boot 2.0
 
riffing on Knative - Scott Andrews
riffing on Knative - Scott Andrewsriffing on Knative - Scott Andrews
riffing on Knative - Scott Andrews
 
Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015
 
Grooscript in Action SpringOne2gx 2015
Grooscript in Action SpringOne2gx 2015Grooscript in Action SpringOne2gx 2015
Grooscript in Action SpringOne2gx 2015
 
Data Migration at Scale with RabbitMQ and Spring Integration
Data Migration at Scale with RabbitMQ and Spring IntegrationData Migration at Scale with RabbitMQ and Spring Integration
Data Migration at Scale with RabbitMQ and Spring Integration
 
Square Pegs, Square Holes: CI/CD That Fits
Square Pegs, Square Holes: CI/CD That FitsSquare Pegs, Square Holes: CI/CD That Fits
Square Pegs, Square Holes: CI/CD That Fits
 
State of Securing Restful APIs s12gx2015
State of Securing Restful APIs s12gx2015State of Securing Restful APIs s12gx2015
State of Securing Restful APIs s12gx2015
 
S1P: Spring Cloud on PKS
S1P: Spring Cloud on PKSS1P: Spring Cloud on PKS
S1P: Spring Cloud on PKS
 
Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs
 
Fast 5 Things You Can Do Now to Get Ready for the Cloud
Fast 5 Things You Can Do Now to Get Ready for the CloudFast 5 Things You Can Do Now to Get Ready for the Cloud
Fast 5 Things You Can Do Now to Get Ready for the Cloud
 
Teaching TDD to Different Learning Styles
Teaching TDD to Different Learning StylesTeaching TDD to Different Learning Styles
Teaching TDD to Different Learning Styles
 
Intro to Reactive Programming
Intro to Reactive ProgrammingIntro to Reactive Programming
Intro to Reactive Programming
 
Intro To Reactive Programming
Intro To Reactive ProgrammingIntro To Reactive Programming
Intro To Reactive Programming
 
Marcin Grzejszczak - Contract Tests in the Enterprise
Marcin Grzejszczak - Contract Tests in the EnterpriseMarcin Grzejszczak - Contract Tests in the Enterprise
Marcin Grzejszczak - Contract Tests in the Enterprise
 
Spring MVC 4.2: New and Noteworthy
Spring MVC 4.2: New and NoteworthySpring MVC 4.2: New and Noteworthy
Spring MVC 4.2: New and Noteworthy
 
Reactive Web Applications
Reactive Web ApplicationsReactive Web Applications
Reactive Web Applications
 
The Beginner’s Guide To Spring Cloud
The Beginner’s Guide To Spring CloudThe Beginner’s Guide To Spring Cloud
The Beginner’s Guide To Spring Cloud
 
Accelerating the Developers' Road to the Cloud at Enterprise Scale
Accelerating the Developers' Road to the Cloud at Enterprise ScaleAccelerating the Developers' Road to the Cloud at Enterprise Scale
Accelerating the Developers' Road to the Cloud at Enterprise Scale
 
Spring Tools 4 - Eclipse and Beyond
Spring Tools 4 - Eclipse and BeyondSpring Tools 4 - Eclipse and Beyond
Spring Tools 4 - Eclipse and Beyond
 
Enable Authentication and Authorization with Azure Active Directory and Sprin...
Enable Authentication and Authorization with Azure Active Directory and Sprin...Enable Authentication and Authorization with Azure Active Directory and Sprin...
Enable Authentication and Authorization with Azure Active Directory and Sprin...
 

More from Tom Henricksen

IBADD Tech Survival 101
IBADD Tech Survival 101IBADD Tech Survival 101
IBADD Tech Survival 101Tom Henricksen
 
Tips to Growing a Successful Business(In 15 Minutes) - Kimberly Baeth
Tips to Growing a Successful Business(In 15 Minutes) - Kimberly BaethTips to Growing a Successful Business(In 15 Minutes) - Kimberly Baeth
Tips to Growing a Successful Business(In 15 Minutes) - Kimberly BaethTom Henricksen
 
Deception of Distrust - Sarah Noll Wilson
Deception of Distrust - Sarah Noll WilsonDeception of Distrust - Sarah Noll Wilson
Deception of Distrust - Sarah Noll WilsonTom Henricksen
 
Marketing, Taxes, Media - Michael Libbie
Marketing, Taxes, Media - Michael LibbieMarketing, Taxes, Media - Michael Libbie
Marketing, Taxes, Media - Michael LibbieTom Henricksen
 
LeadN15 Panel - Dan Topf
LeadN15 Panel - Dan TopfLeadN15 Panel - Dan Topf
LeadN15 Panel - Dan TopfTom Henricksen
 
Socially Responsible Senior Leadership - Desmund Adams
Socially Responsible Senior Leadership - Desmund AdamsSocially Responsible Senior Leadership - Desmund Adams
Socially Responsible Senior Leadership - Desmund AdamsTom Henricksen
 
Head First Java Chapter 8
Head First Java Chapter 8Head First Java Chapter 8
Head First Java Chapter 8Tom Henricksen
 
Head First Java Chapter 7
Head First Java Chapter 7Head First Java Chapter 7
Head First Java Chapter 7Tom Henricksen
 
Head First Java Chapter 6
Head First Java Chapter 6Head First Java Chapter 6
Head First Java Chapter 6Tom Henricksen
 
Head First Java Chapter 5
Head First Java Chapter 5Head First Java Chapter 5
Head First Java Chapter 5Tom Henricksen
 
Head First Java Chapter 4
Head First Java Chapter 4Head First Java Chapter 4
Head First Java Chapter 4Tom Henricksen
 
Head First Java Chapter 3
Head First Java Chapter 3Head First Java Chapter 3
Head First Java Chapter 3Tom Henricksen
 
Head First Java Chapter 2
Head First Java Chapter 2Head First Java Chapter 2
Head First Java Chapter 2Tom Henricksen
 
Head First Java Chapter 1
Head First Java Chapter 1Head First Java Chapter 1
Head First Java Chapter 1Tom Henricksen
 
Technical screening .Net Developer
Technical screening  .Net DeveloperTechnical screening  .Net Developer
Technical screening .Net DeveloperTom Henricksen
 
Boost your tech IQ to boost IT recruiting success
Boost your tech IQ to boost IT recruiting successBoost your tech IQ to boost IT recruiting success
Boost your tech IQ to boost IT recruiting successTom Henricksen
 
Know thy client a technical primer for sales professionals
Know thy client  a technical primer for sales professionalsKnow thy client  a technical primer for sales professionals
Know thy client a technical primer for sales professionalsTom Henricksen
 
Becoming an Advanced Groovy Developer
Becoming an Advanced Groovy DeveloperBecoming an Advanced Groovy Developer
Becoming an Advanced Groovy DeveloperTom Henricksen
 
Grails gotchas and best practices
Grails gotchas and best practicesGrails gotchas and best practices
Grails gotchas and best practicesTom Henricksen
 

More from Tom Henricksen (20)

TechnoLeaders
TechnoLeadersTechnoLeaders
TechnoLeaders
 
IBADD Tech Survival 101
IBADD Tech Survival 101IBADD Tech Survival 101
IBADD Tech Survival 101
 
Tips to Growing a Successful Business(In 15 Minutes) - Kimberly Baeth
Tips to Growing a Successful Business(In 15 Minutes) - Kimberly BaethTips to Growing a Successful Business(In 15 Minutes) - Kimberly Baeth
Tips to Growing a Successful Business(In 15 Minutes) - Kimberly Baeth
 
Deception of Distrust - Sarah Noll Wilson
Deception of Distrust - Sarah Noll WilsonDeception of Distrust - Sarah Noll Wilson
Deception of Distrust - Sarah Noll Wilson
 
Marketing, Taxes, Media - Michael Libbie
Marketing, Taxes, Media - Michael LibbieMarketing, Taxes, Media - Michael Libbie
Marketing, Taxes, Media - Michael Libbie
 
LeadN15 Panel - Dan Topf
LeadN15 Panel - Dan TopfLeadN15 Panel - Dan Topf
LeadN15 Panel - Dan Topf
 
Socially Responsible Senior Leadership - Desmund Adams
Socially Responsible Senior Leadership - Desmund AdamsSocially Responsible Senior Leadership - Desmund Adams
Socially Responsible Senior Leadership - Desmund Adams
 
Head First Java Chapter 8
Head First Java Chapter 8Head First Java Chapter 8
Head First Java Chapter 8
 
Head First Java Chapter 7
Head First Java Chapter 7Head First Java Chapter 7
Head First Java Chapter 7
 
Head First Java Chapter 6
Head First Java Chapter 6Head First Java Chapter 6
Head First Java Chapter 6
 
Head First Java Chapter 5
Head First Java Chapter 5Head First Java Chapter 5
Head First Java Chapter 5
 
Head First Java Chapter 4
Head First Java Chapter 4Head First Java Chapter 4
Head First Java Chapter 4
 
Head First Java Chapter 3
Head First Java Chapter 3Head First Java Chapter 3
Head First Java Chapter 3
 
Head First Java Chapter 2
Head First Java Chapter 2Head First Java Chapter 2
Head First Java Chapter 2
 
Head First Java Chapter 1
Head First Java Chapter 1Head First Java Chapter 1
Head First Java Chapter 1
 
Technical screening .Net Developer
Technical screening  .Net DeveloperTechnical screening  .Net Developer
Technical screening .Net Developer
 
Boost your tech IQ to boost IT recruiting success
Boost your tech IQ to boost IT recruiting successBoost your tech IQ to boost IT recruiting success
Boost your tech IQ to boost IT recruiting success
 
Know thy client a technical primer for sales professionals
Know thy client  a technical primer for sales professionalsKnow thy client  a technical primer for sales professionals
Know thy client a technical primer for sales professionals
 
Becoming an Advanced Groovy Developer
Becoming an Advanced Groovy DeveloperBecoming an Advanced Groovy Developer
Becoming an Advanced Groovy Developer
 
Grails gotchas and best practices
Grails gotchas and best practicesGrails gotchas and best practices
Grails gotchas and best practices
 

Recently uploaded

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Recently uploaded (20)

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

Becoming an Advanced Groovy Developer Spring One 2gx 2015

  • 1. SPRINGONE2GX WASHINGTON, DC Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attributio n-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Becoming an Advanced Groovy Developer By Tom Henricksen @tomhenricksen
  • 2. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Agenda • Design Patterns • Mixing Java and Groovy • Calling other languages 2
  • 3. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Design Patterns What are Design Patterns? Types • Structural • Creational • Behavioral 3
  • 4. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Design Patterns • Why Design Patterns? • Good Communication tools • Don’t force in 4
  • 5. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Design Patterns Iterator pattern • Behavioral • Traverse collections 5
  • 6. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Iterator Pattern 6 // Iterator example – for in for (item in container) { println item } // Iterator example – eachWithIndex colors.eachWithIndex{ item, pos -> printlin “Position $pos contains ‘$item’” } // Iterator example – each (1..3).each { println “Number ${it}”
  • 7. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Design Patterns Adapter Pattern • Structural • Wrap functionality 7
  • 8. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Adaptor Pattern 8 // Adapter example class SquarePegAdapter { def peg def getRadius() { Math.sqrt(((peg.width / 2) * * 2) * 2) } String toString() { “SquarePegAdapter with peg $peg.width and radius $radius” } }
  • 9. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Design Patterns Decorator Pattern • Structural • Add behavior 9
  • 10. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Decorator Pattern 10 // Decorator example class UpperLogger extends Logger { private Logger logger UpperLogger(logger) { this.logger = logger } def log(String message) { logger.log(message.toUpperCase()) } }
  • 11. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Design Patterns Singleton Pattern • Creational • Ensure only one 11
  • 12. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Singleton Pattern 12 // Decorator example class VoteCollector { def votes = 0 private static final INSTANCE = new VoteCollector() static getInstance() { return INSTANCE } private VoteCollector() { } def display() { println "Collector:${hashCode()}, Votes:$votes" } }
  • 13. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Groovy Design Patterns Questions • What design pattern would you add? 13

Editor's Notes

  1. Good afternoon, my name is Tom Henricksen and Welcome to Becoming an Advanced Groovy Developer at Springone 2GX 2015. Thank you for coming to this session. I have been a software developer for over fifteen years dealing with Java, Oracle Technologies, Groovy, and Grails and I live in West Des Moines Iowa. First off, I just want to thank my employer Zirous for this opportunity. At Zirous we are an Oracle Platinum Partner, Hortonworks Partner, ForgeRock Partner and help many companies find technology solutions with Java, Groovy, Grails, Big Data, Identity, and other open source technologies.
  2. Here is today’s agenda, we will start with Groovy Design Patterns in the first part of the presentation. From there we will go into the second section and discuss the Mixing Java and Groovy. If you have any comments just share them during the presentation.
  3. What are design patterns? They are simply solutions to development challenges we encounter daily. It is not a library we add, but more of a template to implement in given situations. Design patterns can be applied in a language such as Groovy. Groovy’s features make some of these easier to implement. One issue that I learned early on is if you implement them in the wrong place you can make things more complicated than they need to be. When I first learned the Singleton pattern I tried to put it every where, many places it didn’t fit. On the whole they can help immensely when implemented correctly. Design patterns are broken up into three categories: 1. Structural 2. Creational 3. Behavioral Using Structural patterns, we can make things work together in a better way. Creational patterns simply make it easy to create the objects we need. The last category of patterns is behavioral and they facilitate communications between our classes.
  4. I think it is helpful for all developers to understand these solution templates to the daily challenges we run into. Perhaps you have read the Gang of Four design patterns book. I personally found that book a bit too abstract. Design patterns originated in building design and architecture and were brought to software development by Kent Beck and Ward Cunningham. When developers discuss proposed solutions design patterns come in handy. We can quickly explain what type of solution we think would work best by using the names of the design patterns. Of course when we read through code using the name of the design pattern in the file name can be very helpful too. Who wants to read through lines of code just to decipher the solution. One important note that I picked up from a talk that Venkat Subramaniam did on design patterns is that we should not force them in but rather let them come out as we develop the code. Like mentioned earlier I had an issue with this as I learned the singleton pattern and tried to force this into too many situations. It caused confusion and I spent a lot time removing most of those. If you are in doubt it can be helpful to share with another developer and get their feedback. https://www.youtube.com/watch?v=YSEcVlYiGIU
  5. The iterator pattern is a behavioral design pattern that allows you to traverse a collection of objects in a consistent manner independent of the type of collection. Iterator Design Pattern You want to traverse a collection of objects in a consistent manner independent of the type of collection An external iterator allows you to control the actual traversal An internal iterator takes care of that—you provide code that needs to be executed for each element in the collection
  6. Groovy has the iterator pattern built right in to many of its closure operators, Here is three examples, the each and eachWithIndex as well as the for .. in loop. Here we have examples of all three starting with the for in, eachWithIndex, and each.
  7. The Adapter Pattern is a structural pattern that (sometimes called the wrapper pattern) allows objects satisfying one interface to be used where another type of interface is expected. There are two typical flavors of the pattern: the delegation flavor and the inheritance flavor. The adapter pattern is a structural design pattern that allows you to repurpose a class with a different interface, allowing it to be used by a system which uses different calling methods.
  8. In this example of an adapter pattern we have defined the getRadius and toString methods. This adapter is for the SquarePeg class. The adapter is sometimes referred to as a wrapper too. Think about how you might “wrap” functionality into an existing class. There are many great examples of adapters in the real world. For instance if you travel to many countries overseas you notice the power plugs are different so we need to get an adapter. In software development this happens a lot when we call a vendor’s API. Perhaps we need add more parameters to call an LDAP service. Adapters can help encapsulate methods using an adapter. Using an adapter can make it so you can reuse code instead rewriting code.
  9. Next up we will talk about the decorator pattern, which like the adapter pattern is a structural design pattern. The decorator’s job is to add behavior to your object. It can enhance your normal behavior without changing the essential interface. We must make sure that the object that has the decorator pattern applied can be used in the same manner as the normal object. We should not need to modify the source code to do this. Decorating a class is different than subclassing, where decorating adds functionality at runtime, subclassing works at compile time. The aim is to make it so that the new functions can be applied to one instance, and, at the same time, still be able to create an original instance that doesn't have the new functions. This allows for mixing multiple decorators for one instance.
  10. In this example of a decorator we add functionality to the logger class. We simply build on the base functionality to make messages upper case in the log. You can easily see how you can enhance the logging more by adding perhaps a timestamp or additional machine information.
  11. Our last pattern we our going to cover this afternoon is the Singleton. Singleton is a creational design pattern that makes sure that you have one instance of a class during runtime and provides a point of access to the instance. As I mentioned earlier in this presentation I learned this design pattern early in my career and tried to over apply this to many situations. We should use the Singleton pattern when we want to make sure one object of a class should be created. Be sure that this is the case, make sure you understand what solution is needed. Many years ago I created a help desk utility that I misunderstood the requirements of and used copious amounts of singletons. This one object should coordinate actions across a system. Maybe there is a resource that cannot be shared so the singleton can control access to it. Other times it could be an issue where creating many objects can be wasteful. A few of the cons of the singleton are They can be hard to test because of the static methods. Could hinder reuse, inheritance for singletons can be very tricky
  12. In this example of a decorator it has a private constructor, so no VoteCollector objects can be created . This instance is private and cannot be modified. The vote collector instance is created once we reference this class even if not needed.
  13. Now it is your turn to talk, here are a few questions for you. What Design Pattern would you add? (30 seconds) Are there any that you think are not needed? (30 seconds) Which one do you use most? (30 seconds) How do you help new members of the team deal with Design Patterns your codebase? (30 seconds)