Let's Play- Overview

991 views

Published on

Introduce play framework from high level to code.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
991
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Let's Play- Overview

  1. 1. LET’S PLAY OverView Xuefeng.Wu 2013.07
  2. 2. AGENDA ! Architecture Good things Bad things
  3. 3. M-V-C
  4. 4. PLAY
  5. 5. ROUTE /users/1 /users/:id controller.Users.get(id:Long)
  6. 6. ACTION request => response object Users extends Controller { def get(id: Long) = Action {request => Ok(<name>User.findById(id).name</name>) } }
  7. 7. OK(<NAME>PLAY</ NAME>) Generates a ‘200 OK’ result. text/xml http body <name>play</name>
  8. 8. HTTP BODY Text, Json, XML, File Action(BodyParsers.parse.json) {request: Request[JsValue] => }
  9. 9. IN ONE SLID /users/:id controller.Users.get(id:Long) object Users extends Controller { def get(id: Long) = Action{request => val user = User.findById(id) Ok(Json.toJson(s””” {“name”: “${user.name}”}”””)) } }
  10. 10. PLAY INTRODUCE The Play Framework combines productivity and performance making it easy to build scalable web applications with Java and Scala. ! ! Play is developer friendly with a "just hit refresh" workflow and built-in testing support. ! ! With Play, applications scale predictably due to a stateless and non-blocking architecture. ! ! By being RESTful by default, including assets compilers, JSON & WebSocket support, ! ! Play is a perfect fit for modern web & mobile applications.
  11. 11. PLAY GOOD THINGS The Play Framework combines productivity and performance making it easy to build scalable web applications with Java and Scala. ! ! Play is developer friendly with a "just hit refresh" workflow and built-in testing support. ! ! With Play, applications scale predictably due to a stateless and non- blocking architecture. ! ! By being RESTful by default, including assets compilers, JSON & WebSocket support, ! ! Play is a perfect fit for modern web & mobile applications.
  12. 12. PRODUCTIVITY just hit refresh v.s. restart jetty type safe v.s. more test
  13. 13. FIX AND HIT
  14. 14. PERFORMANCE compiled v.s. intercept non-blocking v.s. one thread for one request
  15. 15. NON-BLOCKING Iteratee http://www.infoq.com/presentations/Play2
  16. 16. SCALABLE stateless v.s. session akka Cluster
  17. 17. SCALABLE stateless v.s. session akka Cluster http://es.slideshare.net/nicmarti/play-framework-softshake-presentation
  18. 18. BUILT-IN TESTING play.api.test.Helper._
  19. 19. ASSETS COMPILERS CoffeeScript LESS CSS Google Closure Compiler RequireJS
  20. 20. JSON case class RegisterInfo(email: String, password: Option[String], partnerId: Option[String]) implicit val registerInfoReads = Json.reads[RegisterInfo] def result: BusinessResult[CreatedAccount] = Try(request.body.validate[RegisterInfo].get) match { case Success(registerInfo) => business.register(registerInfo) case Failure(e) => FailedResult(invalidJson, List(Messages("invalid.json.format"))) }
  21. 21. PLAY INTRODUCE The Play Framework combines productivity and performance making it easy to build scalable web applications with Java and Scala. ! ! Play is developer friendly with a "just hit refresh" workflow and built-in testing support. ! ! With Play, applications scale predictably due to a stateless and non-blocking architecture. ! ! By being RESTful by default, including assets compilers, JSON & WebSocket support, ! ! Play is a perfect fit for modern web & mobile applications.
  22. 22. MODERN WEB
  23. 23. MODERN WEB ! Designing for mobile first (even if you’re not building a mobile app) Build only single page apps Create and use your own REST API “Sex sells” applies to web apps http://blogs.atlassian.com/2012/01/modern-principles-in-web-development/
  24. 24. ASYNC AsyncResult Streaming HTTP responses Comet sockets WebSockets
  25. 25. DOCUMENT http://www.playframework.com/documentation
  26. 26. NOT SO GOOD The template engine Anorm
  27. 27. THE TEMPLATE ENGINE lack of UI helper reload need compiler meaningless static http://en.wikipedia.org/wiki/Template_engine_(web)
  28. 28. ANORM write SQL by hand less transaction management
  29. 29. REAL TIME
  30. 30. Q&A

×