Download - Let's Play- Overview
LET’S PLAY
OverView
Xuefeng.Wu 2013.07
AGENDA
!
Architecture
Good things
Bad things
M-V-C
PLAY
ROUTE
/users/1
/users/:id controller.Users.get(id:Long)
ACTION
request => response
object Users extends Controller {
def get(id: Long) = Action {request =>
Ok(<name>User.findById(id).name</name>)
}
}
OK(<NAME>PLAY</NAME>)
Generates a ‘200 OK’ result.
text/xml
http body <name>play</name>
HTTP BODY
Text, Json, XML, File
Action(BodyParsers.parse.json){request: Request[JsValue] =>
}
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}”}”””))
}
}
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.
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.
PRODUCTIVITY
just hit refresh v.s. restart jetty
type safe v.s. more test
FIX AND HIT
PERFORMANCE
compiled v.s. intercept
non-blocking v.s. one thread for one request
NON-BLOCKING
Iteratee
http://www.infoq.com/presentations/Play2
SCALABLE
stateless v.s. session
akka Cluster
SCALABLE
stateless v.s. session
akka Cluster
http://es.slideshare.net/nicmarti/play-framework-softshake-presentation
BUILT-IN TESTING
play.api.test.Helper._
ASSETS COMPILERS
CoffeeScript
LESS CSS
Google Closure Compiler
RequireJS
JSONcase 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")))
}
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.
MODERN WEB
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/
ASYNC
AsyncResult
Streaming HTTP responses
Comet sockets
WebSockets
NOT SO GOOD
The template engine
Anorm
THE TEMPLATE ENGINE
lack of UI helper
reload need compiler
meaningless static
http://en.wikipedia.org/wiki/Template_engine_(web)
ANORM
write SQL by hand
less transaction management
REAL TIME
Q&A