SlideShare a Scribd company logo
Groovy and Grails

      Prabhu
prabhu@prabhu-s.com
Groovy
                         • is an agile and dynamic language for JVM
                         • Features inspired from Python, Ruby …
                         • Seamless integration with all existing
                         Java classes and libraries.


• Groovysh and GroovyConsole
• Can run on .Net 2.0 using IKVM
• Latest version 1.5
• http://groovy.codehaus.org
Features
•   Closures
•   Dynamic Methods
•   List & Maps
•   Better XML/Swing Capabilities
Closure
• Statements enclosed within curly braces
  “{}“
• Can be passed around like variables
• Return value either using return
  keyword or the value of last executed
  statement.
Closure (Contd)
square = { it * it }
square (4)
Output = 16

“it” implicit parameter representing the
   passed value.
Closure (Contd)
square {
   it * it
   return 3
}

square (4)
Output = 3 (Since there is an explicit
  return statement!)
Closure (Contd)
square = { param1 ->
   param1 * param1
}

square (3)
Output = 9
Param1 – Named parameter
Factorial using closures
fact = 1               fact = 1
for (i in 2..5) {      (2..5).each {
                         number ->
   fact *= i
                         fact *= number
}                      }
print fact             print fact

                       // (2..5) = Range
Factorial again!
fact = 1
2.upto(5) { num ->
  fact *= num
}
print fact

// Numbers are treated as object.
• upto method generates all number objects
• To each object, the closure gets passed
   around!
Generic Factorial
fact = 1
fun = { n->
       2.upto(n) { num ->
       fact *= num
  }
}

fun(5)
print fact
Dynamic methods
class webcamp {
  def haveTea() {
     println quot;Time for teaquot;
  }
}

camp = new webcamp()
camp.haveTea()
Dynamic methods (Contd)
• Add a new method “haveSamosa”
class webcamp {
   def haveTea() {
         println quot;Time for tea“
   }
}
camp = new webcamp()
camp.haveTea()

webcamp.metaClass.haveSamosa = { ->
  println quot;Have Samosa alsoquot;
}

camp = new webcamp() // Create a fresh object since the class has
   changed!
camp.haveSamosa()
Lists and Maps
• Like python
List = [2,3,4]
Map = [„a‟ : 2, „b‟ : new Date()]
Grails
• Web Framework inspired by RoR
• Latest version is 1.0.1.
   – The one in the DVD is 1.0 and doesn‟t run cleanly in
     windows!
• Grails = Spring MVC 2.5.1 + Hibernate 3 +
  SiteMesh 2.3
• Newbie‟s are unaware that Grails is full and full
  Spring!
• Provides several commands to auto generate
  code.
• Comes bundled with HSQLDB.
Create your first app
• Set environmental variables
  GRAILS_HOME and PATH
• grails create-app firstapp
Directory Structure

                      Controllers
        Domain



            Views


            Sources

            Test cases


            J2EE Web Appln.
First app Demo
• grails create-domain-class <name>
• grails create-controller <name>
• grails run-app (Starts inbuilt Jetty 6.1.4
  server)
• Visit http://localhost:8080/firstapp
• Demo
Features
• Both gsp and jsp are supported.
• Specify constraints
static constraints = {
      username (minLength : 3, maxLength: 8, blank:false)
      password(minLength : 5, maxLength:9, blank:false)
   }


• Specify Optional fields
static optionals = [“middle_name”, “addr2”]
Features (Contd)
• Dynamic finder methods
def search = {
   render(view : „list‟,
        model : [userList :
                      User.findAllByUsernameLike (
                           „%‟ + params.username + „%‟)
                 ]
        )
}

• User.findAllByUsernameLikeAndPassword
  Like
Features (Contd)
• Create Advanced Search criteria using
  Hibernate Criteria Builder.
def criteria = User.createCriteria() // Dynamic method
def results = criteria {
   and (
          like („username‟ , „%‟ + params.username + „%‟)
          le(„age‟, params.age)
          )
}
Render(view:‟list‟, model:[userList : results])
Features (Contd)
• Flash scope - Data will be stored as
  name-value pairs for current request
  and the next request.
• Create custom tags just by creating a
  new file in grails-
  app/taglib/<name>TagLib.groovy
Features (Contd)
• AJAX Support
  – Supports prototype, YUI, DOJO
  – Use render method in your groovy code to
    render text, HTML, JSON or OpenRico
    Response XMLs
• Plays nicely with flex
  – Simply add this
    static expose = [“flex-remoting”]
  – Automatic flex based CRUD generation and
    Domain class to AS3 compilation coming up!
Features (Contd)
• Plays nicely with EJB
  – http://www.infoq.com/articles/grails-ejb-
    tutorial
• Has lots of plugins already!
  – grails install-plugin <name>
  – grails create-plugin <name>
Scalability
• Thanks to Spring and Hibernate, Grails
  is highly scalable and already enterprise
  ready!
RoR Competition?
• No.
  – Instead going to compete with Java based
    frameworks like struts 2, JSF, Seam.
Should I learn?
• If you are a Java guy, then yes.
• Companies like Oracle have already
  started showing full support!
Thanks



Q&A

More Related Content

What's hot

Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
stefanmayer13
 
Understanding the nodejs event loop
Understanding the nodejs event loopUnderstanding the nodejs event loop
Understanding the nodejs event loop
Saurabh Kumar
 
Declarative Infrastructure Tools
Declarative Infrastructure Tools Declarative Infrastructure Tools
Declarative Infrastructure Tools
Yulia Shcherbachova
 
Tweaking performance on high-load projects
Tweaking performance on high-load projectsTweaking performance on high-load projects
Tweaking performance on high-load projects
Dmitriy Dumanskiy
 
Introduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoa
Florent Pillet
 
Handling 20 billion requests a month
Handling 20 billion requests a monthHandling 20 billion requests a month
Handling 20 billion requests a monthDmitriy Dumanskiy
 
JVM performance options. How it works
JVM performance options. How it worksJVM performance options. How it works
JVM performance options. How it works
Dmitriy Dumanskiy
 
Talk KVO with rac by Philippe Converset
Talk KVO with rac by Philippe ConversetTalk KVO with rac by Philippe Converset
Talk KVO with rac by Philippe Converset
CocoaHeads France
 
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
GlobalLogic Ukraine
 
Go Containers
Go ContainersGo Containers
Go Containers
jgrahamc
 
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftReactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwift
Florent Pillet
 
Graphql with Flamingo
Graphql with FlamingoGraphql with Flamingo
Graphql with Flamingo
i-love-flamingo
 
Cascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the StreamsCascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the Streams
mattpodwysocki
 
Scalable Angular 2 Application Architecture
Scalable Angular 2 Application ArchitectureScalable Angular 2 Application Architecture
Scalable Angular 2 Application Architecture
FDConf
 
Async Microservices with Twitter's Finagle
Async Microservices with Twitter's FinagleAsync Microservices with Twitter's Finagle
Async Microservices with Twitter's Finagle
Vladimir Kostyukov
 
Luis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio on RxJS
Luis Atencio on RxJS
Luis Atencio
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
OdessaJS Conf
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency design
Hyejong
 
The What, Why And How of ClojureScript
The What, Why And How of ClojureScriptThe What, Why And How of ClojureScript
The What, Why And How of ClojureScript
Ivan Bokii
 

What's hot (20)

Groovyノススメ
GroovyノススメGroovyノススメ
Groovyノススメ
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
Understanding the nodejs event loop
Understanding the nodejs event loopUnderstanding the nodejs event loop
Understanding the nodejs event loop
 
Declarative Infrastructure Tools
Declarative Infrastructure Tools Declarative Infrastructure Tools
Declarative Infrastructure Tools
 
Tweaking performance on high-load projects
Tweaking performance on high-load projectsTweaking performance on high-load projects
Tweaking performance on high-load projects
 
Introduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoa
 
Handling 20 billion requests a month
Handling 20 billion requests a monthHandling 20 billion requests a month
Handling 20 billion requests a month
 
JVM performance options. How it works
JVM performance options. How it worksJVM performance options. How it works
JVM performance options. How it works
 
Talk KVO with rac by Philippe Converset
Talk KVO with rac by Philippe ConversetTalk KVO with rac by Philippe Converset
Talk KVO with rac by Philippe Converset
 
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
 
Go Containers
Go ContainersGo Containers
Go Containers
 
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftReactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwift
 
Graphql with Flamingo
Graphql with FlamingoGraphql with Flamingo
Graphql with Flamingo
 
Cascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the StreamsCascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the Streams
 
Scalable Angular 2 Application Architecture
Scalable Angular 2 Application ArchitectureScalable Angular 2 Application Architecture
Scalable Angular 2 Application Architecture
 
Async Microservices with Twitter's Finagle
Async Microservices with Twitter's FinagleAsync Microservices with Twitter's Finagle
Async Microservices with Twitter's Finagle
 
Luis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio on RxJS
Luis Atencio on RxJS
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency design
 
The What, Why And How of ClojureScript
The What, Why And How of ClojureScriptThe What, Why And How of ClojureScript
The What, Why And How of ClojureScript
 

Similar to Groovy and Grails talk

What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?
Christophe Porteneuve
 
JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)
jeresig
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
Jonathan Felch
 
MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
Caridy Patino
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Tsuyoshi Yamamoto
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
Marc Chung
 
Groovy.pptx
Groovy.pptxGroovy.pptx
Groovy.pptx
Giancarlo Frison
 
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume LaforgeGroovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Guillaume Laforge
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
Troy Miles
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
Troy Miles
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、GaelykでハンズオンTsuyoshi Yamamoto
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGLChihoon Byun
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for you
Simon Willison
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Guillaume Laforge
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for Java
Charles Anderson
 
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume LaforgeGR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
경주 전
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
loffenauer
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extreme
yinonavraham
 
Groovy
GroovyGroovy
Groovy
Zen Urban
 

Similar to Groovy and Grails talk (20)

What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?
 
JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
 
MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
Groovy.pptx
Groovy.pptxGroovy.pptx
Groovy.pptx
 
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume LaforgeGroovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGL
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for you
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for Java
 
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume LaforgeGR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extreme
 
Groovy
GroovyGroovy
Groovy
 

Recently uploaded

Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptxTaurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
my Pandit
 
Global Interconnection Group Joint Venture[960] (1).pdf
Global Interconnection Group Joint Venture[960] (1).pdfGlobal Interconnection Group Joint Venture[960] (1).pdf
Global Interconnection Group Joint Venture[960] (1).pdf
Henry Tapper
 
chapter 10 - excise tax of transfer and business taxation
chapter 10 - excise tax of transfer and business taxationchapter 10 - excise tax of transfer and business taxation
chapter 10 - excise tax of transfer and business taxation
AUDIJEAngelo
 
FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134
LR1709MUSIC
 
Improving profitability for small business
Improving profitability for small businessImproving profitability for small business
Improving profitability for small business
Ben Wann
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
taqyed
 
Filing Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed GuideFiling Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed Guide
YourLegal Accounting
 
Digital Transformation in PLM - WHAT and HOW - for distribution.pdf
Digital Transformation in PLM - WHAT and HOW - for distribution.pdfDigital Transformation in PLM - WHAT and HOW - for distribution.pdf
Digital Transformation in PLM - WHAT and HOW - for distribution.pdf
Jos Voskuil
 
Attending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learnersAttending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learners
Erika906060
 
Project File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdfProject File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdf
RajPriye
 
Exploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social DreamingExploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social Dreaming
Nicola Wreford-Howard
 
April 2024 Nostalgia Products Newsletter
April 2024 Nostalgia Products NewsletterApril 2024 Nostalgia Products Newsletter
April 2024 Nostalgia Products Newsletter
NathanBaughman3
 
Discover the innovative and creative projects that highlight my journey throu...
Discover the innovative and creative projects that highlight my journey throu...Discover the innovative and creative projects that highlight my journey throu...
Discover the innovative and creative projects that highlight my journey throu...
dylandmeas
 
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdfMeas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
dylandmeas
 
Business Valuation Principles for Entrepreneurs
Business Valuation Principles for EntrepreneursBusiness Valuation Principles for Entrepreneurs
Business Valuation Principles for Entrepreneurs
Ben Wann
 
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBdCree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
creerey
 
Cracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptxCracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptx
Workforce Group
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
SynapseIndia
 
Affordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n PrintAffordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n Print
Navpack & Print
 
Pitch Deck Teardown: RAW Dating App's $3M Angel deck
Pitch Deck Teardown: RAW Dating App's $3M Angel deckPitch Deck Teardown: RAW Dating App's $3M Angel deck
Pitch Deck Teardown: RAW Dating App's $3M Angel deck
HajeJanKamps
 

Recently uploaded (20)

Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptxTaurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
 
Global Interconnection Group Joint Venture[960] (1).pdf
Global Interconnection Group Joint Venture[960] (1).pdfGlobal Interconnection Group Joint Venture[960] (1).pdf
Global Interconnection Group Joint Venture[960] (1).pdf
 
chapter 10 - excise tax of transfer and business taxation
chapter 10 - excise tax of transfer and business taxationchapter 10 - excise tax of transfer and business taxation
chapter 10 - excise tax of transfer and business taxation
 
FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134
 
Improving profitability for small business
Improving profitability for small businessImproving profitability for small business
Improving profitability for small business
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
 
Filing Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed GuideFiling Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed Guide
 
Digital Transformation in PLM - WHAT and HOW - for distribution.pdf
Digital Transformation in PLM - WHAT and HOW - for distribution.pdfDigital Transformation in PLM - WHAT and HOW - for distribution.pdf
Digital Transformation in PLM - WHAT and HOW - for distribution.pdf
 
Attending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learnersAttending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learners
 
Project File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdfProject File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdf
 
Exploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social DreamingExploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social Dreaming
 
April 2024 Nostalgia Products Newsletter
April 2024 Nostalgia Products NewsletterApril 2024 Nostalgia Products Newsletter
April 2024 Nostalgia Products Newsletter
 
Discover the innovative and creative projects that highlight my journey throu...
Discover the innovative and creative projects that highlight my journey throu...Discover the innovative and creative projects that highlight my journey throu...
Discover the innovative and creative projects that highlight my journey throu...
 
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdfMeas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
 
Business Valuation Principles for Entrepreneurs
Business Valuation Principles for EntrepreneursBusiness Valuation Principles for Entrepreneurs
Business Valuation Principles for Entrepreneurs
 
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBdCree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
 
Cracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptxCracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptx
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
 
Affordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n PrintAffordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n Print
 
Pitch Deck Teardown: RAW Dating App's $3M Angel deck
Pitch Deck Teardown: RAW Dating App's $3M Angel deckPitch Deck Teardown: RAW Dating App's $3M Angel deck
Pitch Deck Teardown: RAW Dating App's $3M Angel deck
 

Groovy and Grails talk

  • 1. Groovy and Grails Prabhu prabhu@prabhu-s.com
  • 2. Groovy • is an agile and dynamic language for JVM • Features inspired from Python, Ruby … • Seamless integration with all existing Java classes and libraries. • Groovysh and GroovyConsole • Can run on .Net 2.0 using IKVM • Latest version 1.5 • http://groovy.codehaus.org
  • 3. Features • Closures • Dynamic Methods • List & Maps • Better XML/Swing Capabilities
  • 4. Closure • Statements enclosed within curly braces “{}“ • Can be passed around like variables • Return value either using return keyword or the value of last executed statement.
  • 5. Closure (Contd) square = { it * it } square (4) Output = 16 “it” implicit parameter representing the passed value.
  • 6. Closure (Contd) square { it * it return 3 } square (4) Output = 3 (Since there is an explicit return statement!)
  • 7. Closure (Contd) square = { param1 -> param1 * param1 } square (3) Output = 9 Param1 – Named parameter
  • 8. Factorial using closures fact = 1 fact = 1 for (i in 2..5) { (2..5).each { number -> fact *= i fact *= number } } print fact print fact // (2..5) = Range
  • 9. Factorial again! fact = 1 2.upto(5) { num -> fact *= num } print fact // Numbers are treated as object. • upto method generates all number objects • To each object, the closure gets passed around!
  • 10. Generic Factorial fact = 1 fun = { n-> 2.upto(n) { num -> fact *= num } } fun(5) print fact
  • 11. Dynamic methods class webcamp { def haveTea() { println quot;Time for teaquot; } } camp = new webcamp() camp.haveTea()
  • 12. Dynamic methods (Contd) • Add a new method “haveSamosa” class webcamp { def haveTea() { println quot;Time for tea“ } } camp = new webcamp() camp.haveTea() webcamp.metaClass.haveSamosa = { -> println quot;Have Samosa alsoquot; } camp = new webcamp() // Create a fresh object since the class has changed! camp.haveSamosa()
  • 13. Lists and Maps • Like python List = [2,3,4] Map = [„a‟ : 2, „b‟ : new Date()]
  • 14. Grails • Web Framework inspired by RoR • Latest version is 1.0.1. – The one in the DVD is 1.0 and doesn‟t run cleanly in windows! • Grails = Spring MVC 2.5.1 + Hibernate 3 + SiteMesh 2.3 • Newbie‟s are unaware that Grails is full and full Spring! • Provides several commands to auto generate code. • Comes bundled with HSQLDB.
  • 15. Create your first app • Set environmental variables GRAILS_HOME and PATH • grails create-app firstapp
  • 16. Directory Structure Controllers Domain Views Sources Test cases J2EE Web Appln.
  • 17. First app Demo • grails create-domain-class <name> • grails create-controller <name> • grails run-app (Starts inbuilt Jetty 6.1.4 server) • Visit http://localhost:8080/firstapp • Demo
  • 18. Features • Both gsp and jsp are supported. • Specify constraints static constraints = { username (minLength : 3, maxLength: 8, blank:false) password(minLength : 5, maxLength:9, blank:false) } • Specify Optional fields static optionals = [“middle_name”, “addr2”]
  • 19. Features (Contd) • Dynamic finder methods def search = { render(view : „list‟, model : [userList : User.findAllByUsernameLike ( „%‟ + params.username + „%‟) ] ) } • User.findAllByUsernameLikeAndPassword Like
  • 20. Features (Contd) • Create Advanced Search criteria using Hibernate Criteria Builder. def criteria = User.createCriteria() // Dynamic method def results = criteria { and ( like („username‟ , „%‟ + params.username + „%‟) le(„age‟, params.age) ) } Render(view:‟list‟, model:[userList : results])
  • 21. Features (Contd) • Flash scope - Data will be stored as name-value pairs for current request and the next request. • Create custom tags just by creating a new file in grails- app/taglib/<name>TagLib.groovy
  • 22. Features (Contd) • AJAX Support – Supports prototype, YUI, DOJO – Use render method in your groovy code to render text, HTML, JSON or OpenRico Response XMLs • Plays nicely with flex – Simply add this static expose = [“flex-remoting”] – Automatic flex based CRUD generation and Domain class to AS3 compilation coming up!
  • 23. Features (Contd) • Plays nicely with EJB – http://www.infoq.com/articles/grails-ejb- tutorial • Has lots of plugins already! – grails install-plugin <name> – grails create-plugin <name>
  • 24. Scalability • Thanks to Spring and Hibernate, Grails is highly scalable and already enterprise ready!
  • 25. RoR Competition? • No. – Instead going to compete with Java based frameworks like struts 2, JSF, Seam.
  • 26. Should I learn? • If you are a Java guy, then yes. • Companies like Oracle have already started showing full support!