single-page applications and grails

23
SINGLE-PAGE APPLICATIONS & GRAILS Álvaro Sánchez-Mariscal

Upload: alvaro-sanchez-mariscal

Post on 10-May-2015

3.860 views

Category:

Technology


0 download

DESCRIPTION

Talk about how to deal with Single-page applications and Grails

TRANSCRIPT

Page 1: Single-page applications and Grails

SINGLE-PAGE APPLICATIONS &

GRAILS

Álvaro Sánchez-Mariscal

Page 2: Single-page applications and Grails

About me

Passionate software developer. Founder & CEO of Salenda and Escuela

de Groovy. Groovy/Grails lover since 2007.

Page 3: Single-page applications and Grails

Typical Grails architecture Grails is an MVC, where:

Model is implemented using POGO’s for GORM (Hibernate).

Views are rendered on the server side using GSP’s and taglibs.

Controllers are Groovy classes with methods as actions.

Page 4: Single-page applications and Grails

So what the hell is a SPI application?

Page 5: Single-page applications and Grails
Page 6: Single-page applications and Grails

A SPI web app is…

A web application where you can navigate without any page refresh.

REST is used to communicate with the server.

The MVC is in the browser, written in Javascript, where:The model are Javascript classes.The views are written in HTML.The controller, services, etc. are also written in

Javascript.

Page 7: Single-page applications and Grails

Did you say Javascript?!?

Really?!?

WTF!

WTF!

Page 8: Single-page applications and Grails

Some people like Javascript

Page 9: Single-page applications and Grails

And why the hell should I

care about SPI?

Page 10: Single-page applications and Grails

Because it has some advantages It’s faster, because:

Modern browsers have faster Javascript engines.

Only the data is sent, not the full markup. It has a better user experience,

because:Data refreshes instantly.

It may be easier for the developer:If you choose the right framework, you don’t

have to deal with events or callbacks.

Page 11: Single-page applications and Grails

But, it also has some cons What happens if there is no Javascript?

Are you going to gracefully degrade? How do we deal with server

communication failures? Can I still use the application without an

Internet connection? Am I going to replicate the MVC in the

client? Again? In Javascript?

Page 12: Single-page applications and Grails

Ok. And how do I implement it using Grails?

Page 13: Single-page applications and Grails

Less server logic

Your Grails application gets simplified. Just use GORM (or any other backend)

with a REST API.Implementing a REST API with Grails is

really easy. Just focus on:

Transactions.Data retrieving and storing.Security / authentication.Scalability

Page 14: Single-page applications and Grails

And do I really need a Grails application for

that?

Page 15: Single-page applications and Grails

Not really

You can use Vert.x. Or if you want to be really cool, use

Node.js. Even if you are really bored, you can

just do it in Java…

Page 16: Single-page applications and Grails

News from this morning

In Grails 3.0 you will have application profiles:Servlet “classic” profile.Lightweight profile.REST profile.

Page 17: Single-page applications and Grails

Ok with the server side. What can I do with the

client?

Page 18: Single-page applications and Grails

There’s lot of frameworks

Page 19: Single-page applications and Grails

Comprehensive comparision Todo MVC, by Addy Osmani

and Sindre Sorhus.

http://addyosmani.github.com/todomvc/

Page 20: Single-page applications and Grails

Similar features

Models.Domain classes.

Views and templates.GSP’s and templates.

{{ }}${}

Controllers. Routing.

URL Mappings.

}

Page 21: Single-page applications and Grails

Gotchas

Are views on the client really the best option? What about….?i18n?Security?Caching?

How do we handle dependency management in our Javascript code?

Page 22: Single-page applications and Grails

Show me some code please!

Page 23: Single-page applications and Grails

That’s all!Thanks!

Álvaro Sánchez-Mariscal@alvaro_sanchez