Hands on web development with play 2.0

472 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
472
On SlideShare
0
From Embeds
0
Number of Embeds
21
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Hands on web development with play 2.0

  1. 1. Hands-on Web Development with Play 2.0! Abbas Raza Jean-Baptiste Volta
  2. 2. Gratitude YOU for stopping by!! SVCC for organizing the CampGuillaime Bort for Play Framework
  3. 3. Game PlanPlay Framework Primer (~ 15 min) - Concepts - Architecture - Artifacts It’s Play time (Rest of session) - Setting up Play - Building App Step-by-Step
  4. 4. What’s Play?Designed by web developers for web developersBrings high-productivity web development tothe JVMGreatly enhances developer experience (DX)
  5. 5. Full stack web frameworkJava and Scala supportHigh productivityStateless architectureHTTP centricTypesafeAsynchronousHighly scalableIntegrated testing
  6. 6. High ProductivityMake changes and hit reload in Java world!!Compile-time checkingType-safeConsoleBuilt-in serverUseful error reporting
  7. 7. Compile-time CheckingChecks almost all the artifacts at compile-time – Java/Scala code – Templates – Routes – Config – Javascript (via Google Closure) – LESS – Coffeescript
  8. 8. Stack trace – Ring a bell?!
  9. 9. Error ReportingBrowser error reportingSimplified and useful info
  10. 10. Error Reporting
  11. 11. HTTP CentricDesigned around HTTP, hence statelessState either at client or in persistence layerBack button works!Does not fight HTTP or the browser - leverages the power of HTTP
  12. 12. Why complicate URLs?http://www.coolsite.com/cooler/fe/l=en_US/p/Organizer/CoolerID=9909873008/a=90875276_2885276/invalidateCoolerCache=true/b_c=119/b_otsc=SHR/b_otsi=SPIUUB/s_ev20=jhuC%7CSHR%7COTSI%7CSPICFB/s_pt=REP,HUY,SLO,EE2,FRE,FER#provin=mic
  13. 13. Clean URL DesignURL design part of the application designURL is an interface – a contract not implementationURLs are human and machine friendlyFor instancehttp://localhost:9000/#/projects/3/tasks
  14. 14. Modern Web DevelopmentHTML5CoffeeScriptLESSBootstrap
  15. 15. TestingSpec2 - Default way to testTest controller, router, templateTest from browser
  16. 16. Cloud DeploymentHerokuCloudFoundryOpenShiftCloudbees
  17. 17. Architecture
  18. 18. Downloading & InstallationDownload the binaries from http://www.playframework.com/down loadLatest version – 2.0.4Unzip it to any locationAdd play to path
  19. 19. Create New ProjectRun the following command$ play new coolApp“Start” the application with$ cd coolApp$ play run
  20. 20. Directory Structure
  21. 21. Application ConfigurationConfiguration properties for any application.Examples include database connection info.File located at: <Project>/conf/application.confA typical entry looks like: – db.default.driver=org.h2.Driver
  22. 22. application.conf
  23. 23. RouterWhat: Routes requests to appropriate controllerWhere: File located at: <Project>/conf/routesTypical entries:GET / controllers.Application.index
  24. 24. routes
  25. 25. ControllersController serves requestsContains business logicLocated at <project>/app/controllers
  26. 26. Controllerspackage controllersimport play.api._import play.api.mvc._object Application extends Controller { def index = Action { Ok("Hello, Rockstar") }}
  27. 27. TemplatesTemplate encapsulates HTML to be renderedIs a Scala functionIs type-safeAre compiled into classes for run-time
  28. 28. Templates@(user: User)(body: Html)<html> <body> <header> <dl id="user"> <dt>@user.name</dt> </dl> </header> <section id="main"> @body </section> </body></html>
  29. 29. IDE SupportEclipse – eclipsifyIntelliJ – ideaNetbeans – netbeansScalaIDE
  30. 30. Free Online Scala Course by Martin Oderskyhttp://www.coursera.org/course/prog fun
  31. 31. It’s Play timeImplement a Lean Startup conceptLean Startup Movement mandates validating the pain point before building any productStep-by-step development of the application from scratch
  32. 32. Thank You!!
  33. 33. Referenceshttp://www.playframework.comPlay 2 with Scala in Action by Peter Hilton, Erik Bakker, Francisco Canedo
  34. 34. Image References‘Lets play’ - http://www.drpeppersnapplegroup.com/smedia/www/2011/04/11/img-lets- play460x300_223742710844.jpg‘Architecture diagram’ – http://www.playframework.org

×