Transcript
Page 1: Let's Play- Overview

LET’S PLAY

OverView

Xuefeng.Wu 2013.07

Page 2: Let's Play- Overview

AGENDA

!

Architecture

Good things

Bad things

Page 3: Let's Play- Overview

M-V-C

Page 4: Let's Play- Overview

PLAY

Page 5: Let's Play- Overview

ROUTE

/users/1

/users/:id controller.Users.get(id:Long)

Page 6: Let's Play- Overview

ACTION

request => response

object Users extends Controller {

def get(id: Long) = Action {request =>

Ok(<name>User.findById(id).name</name>)

}

}

Page 7: Let's Play- Overview

OK(<NAME>PLAY</NAME>)

Generates a ‘200 OK’ result.

text/xml

http body <name>play</name>

Page 8: Let's Play- Overview

HTTP BODY

Text, Json, XML, File

Action(BodyParsers.parse.json){request: Request[JsValue] =>

}

Page 9: Let's Play- Overview

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}”}”””))

}

}

Page 10: Let's Play- Overview
Page 11: Let's Play- Overview

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.

Page 12: Let's Play- Overview

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.

Page 13: Let's Play- Overview

PRODUCTIVITY

just hit refresh v.s. restart jetty

type safe v.s. more test

Page 14: Let's Play- Overview

FIX AND HIT

Page 15: Let's Play- Overview

PERFORMANCE

compiled v.s. intercept

non-blocking v.s. one thread for one request

Page 16: Let's Play- Overview

NON-BLOCKING

Iteratee

http://www.infoq.com/presentations/Play2

Page 17: Let's Play- Overview

SCALABLE

stateless v.s. session

akka Cluster

Page 18: Let's Play- Overview

SCALABLE

stateless v.s. session

akka Cluster

http://es.slideshare.net/nicmarti/play-framework-softshake-presentation

Page 19: Let's Play- Overview
Page 20: Let's Play- Overview
Page 21: Let's Play- Overview
Page 22: Let's Play- Overview
Page 23: Let's Play- Overview
Page 24: Let's Play- Overview
Page 25: Let's Play- Overview
Page 26: Let's Play- Overview
Page 27: Let's Play- Overview
Page 28: Let's Play- Overview
Page 29: Let's Play- Overview
Page 30: Let's Play- Overview
Page 31: Let's Play- Overview
Page 32: Let's Play- Overview
Page 33: Let's Play- Overview
Page 34: Let's Play- Overview

BUILT-IN TESTING

play.api.test.Helper._

Page 35: Let's Play- Overview

ASSETS COMPILERS

CoffeeScript

LESS CSS

Google Closure Compiler

RequireJS

Page 36: Let's Play- Overview

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")))

}

Page 37: Let's Play- Overview

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.

Page 38: Let's Play- Overview

MODERN WEB

Page 39: Let's Play- Overview

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/

Page 40: Let's Play- Overview

ASYNC

AsyncResult

Streaming HTTP responses

Comet sockets

WebSockets

Page 41: Let's Play- Overview

DOCUMENT

http://www.playframework.com/documentation

Page 42: Let's Play- Overview

NOT SO GOOD

The template engine

Anorm

Page 43: Let's Play- Overview

THE TEMPLATE ENGINE

lack of UI helper

reload need compiler

meaningless static

http://en.wikipedia.org/wiki/Template_engine_(web)

Page 44: Let's Play- Overview

ANORM

write SQL by hand

less transaction management

Page 45: Let's Play- Overview

REAL TIME

Page 46: Let's Play- Overview

Q&A

Page 47: Let's Play- Overview

Top Related