Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Single-page applications and Grails


Published on

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

Published in: Technology

Single-page applications and Grails

  1. 1. Álvaro Sánchez-Mariscal
  2. 2. About me Passionate software developer. Founder & CEO of Salenda and Escuela de Groovy. Groovy/Grails lover since 2007.
  3. 3. 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.
  4. 4. So what the hell isa SPI application?
  5. 5. 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.
  6. 6. Did you sayJavascript?!? WTF! WTF! Really?!?
  7. 7. Some people like Javascript
  8. 8. And why the hell should I care about SPI?
  9. 9. 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.
  10. 10. 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?
  11. 11. Ok. And how do Iimplement it using Grails?
  12. 12. 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
  13. 13. And do I really needa Grails application for that?
  14. 14. 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…
  15. 15. News from this morning In Grails 3.0 you will have application profiles:  Servlet “classic” profile.  Lightweight profile.  REST profile.
  16. 16. Ok with the server side. What can Ido with the client?
  17. 17. There’s lot of frameworks
  18. 18. Comprehensive comparision Todo MVC, by Addy Osmani and Sindre Sorhus.
  19. 19. Similar features Models. }  Domain classes. Views and templates.  GSP’s and templates. {{ }}  ${} Controllers. Routing.  URL Mappings.
  20. 20. 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?…
  21. 21. Show me some code please!
  22. 22. That’s all! Thanks!Álvaro Sánchez-Mariscal @alvaro_sanchez