Groovy and Grails intro
Upcoming SlideShare
Loading in...5
×
 

Groovy and Grails intro

on

  • 3,830 views

A sample introduction to Groovy and Grails. It´s not finished yet.

A sample introduction to Groovy and Grails. It´s not finished yet.

Statistics

Views

Total Views
3,830
Views on SlideShare
3,807
Embed Views
23

Actions

Likes
5
Downloads
90
Comments
0

4 Embeds 23

http://www.slideshare.net 20
http://localhost:8080 1
http://www.techgig.com 1
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

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 Grails intro Groovy and Grails intro Presentation Transcript

  • Groovy and Grails introduction A pragmatic view Miguel Ángel Pastor Olivar miguelinlas3 at gmail dot com http://miguelinlas3.blogspot.com http://twitter.com/miguelinlas3
  • Spring Jetty Database Eclipse Web Architecture Java IntelliJ DSL's Software Patterns Maven Groovy Tomcat Unit Testing ByteCode Agile Netbeans Dynamic Languages Domain Design Dependency Injection Grails Sitemesh Hibernate Plugin Architecture
  • Java Platform
  • Java Platform
    • Java is a platform, not a language
    • Interprets bytecode (.class files)
    • Multiple platform support (Linux, OSx,...)
    • Garbage collection
    • Java Language
    • . . .
  • Java Platform
    • JSR 924: Virtual Machine Specification
    • JSR 901: Java Language Specification
    • JSR 241: Groovy Language Specification
    • JSR 274: Bean Shell Scripting Language
    • JSR 292: Supporting Dynamically Typed Languages (JavaScript,Scala,Python, . . .)
  • Java Platform
    • DaVinci Machine: OpenJDK subproject
    • Multiple Language support (especially dynamic)
    • JVM Extensions
    • Co-existing with Java
    • Common base model (garbage collection, model execution, . . . )
  • Groovy Features
  • Groovy
    • Dynamic Language for the JVM
    • Additional power features like Python, Ruby and Smalltalk
    • Modern programming features to Java developers
    • DSLs: easy to read and maintain
    • Writing shell and build script easy (Ant DSL,OO)
  • Groovy
    • Strong typing (optional)
    • Duck typing
    • Java Object Model
    • Closures: High Order Functions
    • Easy Java Integration
    • Similar to Java syntax
  • Installing Groovy
    • Download latest release: download
    • Set environment variable GROOVY_HOME
    • Add GROOVY_HOMEin to the path
    • Open a console and type: groovy -v
    • Ready to work!
  • Groovy Datatypes
    • Everything is a object
    • Optional typing
    • Overriding operators
    • Working with strings
    • Working with regular expressions
    • Working with numbers
  • Groovy Collections
    • Working with ranges
    • Working with lists
    • Working with maps
    • Concurrent modifications
  • Working with closures
    • Piece of code wrapped up as an object
    • Syntax: code in curly braces
    • Assign it to a variable
    • Using methods as closures
            • reference.&someMethod
    • Calling them explicitly
    • Return from closures
  • Control Structures
    • Working with if-else
    • Working with switch
    • Working with while
    • Iterating over closures
    • Return values from if/else
    • Return values from exception handlers
  • Object Orientation
    • Similar to Java Model
    • Methods and fields: modifiers are not needed
    • Positional and named parameters
    • Dynamics:
                • ObjReference.'method-name'
    • Coercion with as operator
    • Coercion in assignment
    • Type aliasing
  • Database programming
    • SQL easier
    • SQL more Groovy
    • Performing read queries
    • Performing write queries
    • A practical example
  • Working with builders
    • Domain Specific Languages hype
    • Easy to read and maintain
    • Building DSL: outside the limits
    • Using DSL: building RCP apps
  • References
    • http://groovy.codehaus.org/Documentation
    • Groovy in Action ( Second Edition Early Access )
    • Programming Groovy
    • Neo Metrics products: AquaBM, UserMgmt
    • Surf the web!
  • Grails Features
  • Motivations and pros
    • Unnecessary complexity (DRY)
    • Grails,Rails,Django, TurboGears
    • Reduce complexity
    • Built on top proven technologies
    • Full stack development
    • SpringSource
  • Architecture (I)
    • ORM built on Hibernate
    • Views technologies: Groovy Server Pages
    • Controller layer built on Spring MVC
    • Command layer based on Gant
    • Embedded Tomcat (and Jetty). Fly reloading
    • Depedency Injection based on Spring
    • Support for internazionalitation
  • Architecture (II)
    • Transactional service layer (Spring´s transactions)
    • Groovy power
    • Extensive use of Domain Specific Languages
    • Plugins architecture
  • Installing Grails
    • Download latest release: download
    • Set environment variable GRAILS_HOME
    • Add GRAILS_HOMEin to the path
    • Open a console and type: grails help
    • Ready to work!
  • Beginning Grails
    • Our first Grails application
    • Setting up an IDE: Spring Tool Suite
    • Convention over configuration
  • Beginning Grails
    • Running application: grails run-app
    • Testing application: grails test-app
    • Deploying application: grails war
    • Servlet 2.4+ container
  • GORM (I)
    • Creating domain class: grails create-domain-class
    • Create operation
    • Read operation
    • Update operation
    • Delete operation
  • GORM (II)
    • Domain modeling: POGO
    • Asocciation: one to one
    • Association: one to many
    • Association: many to many
    • Inheritance
    • Performance tips
    • Cascading updates and deletes
  • GORM (III)
    • Basics querying: List, retrieve by id
    • Dynamic finders: findBy, findByAll
    • Method expressions: findBy([Property][Comparator][Boolean Operator])?[Property][Comparator]
    • Criteria: building complex queries
    • Programmatic transactions: withTransaction
  • Controllers (I)
    • Handling requests, preparing responses
    • Class *Controller in grails-app/controllers
    • Each closure maps to a URI
    • Available scopes
          • ServletContext
          • Session
          • Request
          • Params
          • Flash
  • Controllers (II)
    • Model and View: a model is a map
    • Explicit model return or controller properties
    • Rendering views: grails-app/views/controller/actionName.gsp
    • Use of render. Rendering xml, json
    • More concepts: interceptors, filters
  • Groovy Server Pages (I)
    • View technology: similar to JSP or ASP
    • HTML + tags
    • <% %> embed code (discouraged!!)
    • Prefedined variables
          • Application
          • ApplicationContext
          • Flash
          • GrailsApplication
          • Out, params, request, response, session webrequest
  • Groovy Server Pages (II)
    • Page directives: import classes
    • Views and templates.
    • GSP Builting Tags: <g:XXX>
            • Logic and iteration
            • Search and filtering
            • Links and resources
            • Form and fields
  • The service layer (I)
    • Not embed application logic in controllers
    • New service: grails create-service
    • Transacional by default: static transactional = false
    • Depedency injection by convention
    • Reusable logic
    • Use from Java classes
  • References
    • http://grails.org/doc/latest/
    • Grails in action: http://www.manning.com/gsmith/
    • The Definitive Guide to Grails, Second Edition
    • http://www.grailstutorials.com/home/
  • Real examples
  • Some real examples
    • Cronos: sample management app
    • Doing REST in Grails
  • Thank you very much all for coming!