Upcoming SlideShare
Loading in...5
×
 

Groovy and noteworthy

on

  • 771 views

What is Groovy. Why Groovy is an agile dynamic language? What makes Groovy special? Groovy tool set. Getting started from suggestions.

What is Groovy. Why Groovy is an agile dynamic language? What makes Groovy special? Groovy tool set. Getting started from suggestions.

Statistics

Views

Total Views
771
Views on SlideShare
605
Embed Views
166

Actions

Likes
1
Downloads
3
Comments
0

2 Embeds 166

http://webdizz.name 159
https://twitter.com 7

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Groovy and noteworthy Groovy and noteworthy Presentation Transcript

    • Groovy and Noteworthy Izzet Mustafayev@EPAM Systems @webdizz http://webdizz.name
    • Agenda ● Groovy ○ Specials ○ Basics ○ Infrastructure ● Demo ● Getting Started
    • Groovy Specials
    • Groovy is an agile dynamic language
    • ​println 'Hello World​​​​​​​!'​​
    • Java is a Groovy but Groovy is not Java
    • Groovy supports DSL
    • Groovy supports DSL ● A flexible syntax ● Closures ● Meta-programming ● Operator overloading ● No dots and commas
    • Groovy provides statically type check
    • Groovy provides statically type check @groovy.transform.TypeChecked void method() { // do nothing } ​
    • Groovy Basics
    • Groovy Shell
    • Omission of get/set methods ​class Person { String name String email } def person = new Person(name: 'me') person.email = 'email@domain.com' println person.name// me println person.email// email@domain.com ​
    • Initializing beans with named parameters ​class Person { String name String email } def person = new Person(name: 'me') person.email = 'email@domain.com' println person.name// me println person.email// email@domain.com ​
    • Context operations using with class Person { String name String email } def person = new Person(name: 'me', email: 'email@domain.com') person.with{ println name// me println email// email@domain.com }
    • GStrings (interpolation, multiline) def param = 'param' def groovyString = """ There is a ‘${param}’ param """ println groovyString​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​// There is a ‘param’ param
    • Native syntax for data structures def list = [1, 4, 6, 9] println list[-2] // 6 def map = [UA: 'Ukraine', UK: 'United Kingdom'] println map.UA // Ukraine ​def range = 10..20 println range[2] //12 ​
    • Elvis operator for default values def name = null println name != null ? name : "Unknown" // Unknown println name ?: "Unknown" // Unknown name = 'name' println name ?: "Unknown" // name
    • Safe graph navigation if (order != null) { if (order.getCustomer() != null) { if (order.getCustomer().getAddress() != null) { Address address; address = order.getCustomer().getAddress() System.out.println(address); } } } println order?.customer?.address ​
    • Closures printSum = { a, b -> print a+b } printSum(5, 7)// 12 upperCasedList = ['a','b','c','d']. collect{ it.toUpperCase() } println upperCasedList // A, B, C, D ​
    • Metaprogramming String.metaClass.cons2var = { -> String res = '' delegate.toLowerCase() .tokenize('_') .each{ s -> res+=res?s.capitalize():s } res } println "SAMPLE_VAR".cons2var() //sampleVar
    • Groovy Infrastructure
    • Gradle - http://gradle.org/ ● Strong yet flexible conventions ● Manageable and understandable builds ● Follows convention over configuration approach ● Great plug-ins ecosystem
    • Spock - https://github.com/spockframework/spock ● Testing and specification framework ● JUnit compatible ● Highly expressive specification language
    • Easyb - http://easyb.org/ ● Behavior driven development framework ● Specifications are written in Groovy and run via a Java runner, command line, Maven or Ant ● Supports a few different styles of specifications ranging from RSpec's it to a story based DSL with givens, whens, and thens
    • Grails - http://grails.org/ ● Grails is an Open Source, full stack web application framework for the JVM ● Based on Spring, Hibernate, Sitemesh, Quartz etc. ● There are a lot of plug-ins
    • Griffon - http://griffon.codehaus.org ● Desktop development framework inspired in Grails ● Primarily Swing based however supports SWT, Pivot, GTK and JavaFX too ● Growing plugin system (80+ plugins)
    • Gaelyk - http://gaelyk.appspot.com ● Google App Engine development framework based on Groovy and Groovlets ● Emerging plugin system
    • GPars - http://gpars.codehaus.org/ ● Provides DSL and concurrent friendly methods for collections ● Supports Actors and STM ● Dataflow concurrency model
    • CodeNarc - http://codenarc.sourceforge.net/ ● Static analysis for Groovy code ● Over 175 rules to detect defects, bad practices, style issues etc. ● Build tools and Sonar integration
    • GVM - http://gvmtool.net/ ● Manages parallel Versions of multiple SDKs ● Convenient command line interface ● Inspired by RVM ● Supports Groovy, Grails, Gradle etc ● Unfortunately does not work for Win
    • GroovyServ - http://kobo.github.io/groovyserv/ ● Improves Groovy’s startup time ● Works for Win
    • Getting Started
    • http://groovy.codehaus.org/
    • Groovy in Action* by Dierk König ● Groovy committer since 2004 ● Frequent conference speaker ● Contributor to several agile and testing books
    • Programming Groovy 2 by Venkat Subramaniam ● An award-winning author ● Famous Agile Guru ● Frequent conference speaker
    • Thank You! Groovy and Noteworthy Izzet Mustafayev@EPAM Systems @webdizz http://webdizz.name