Designing a Play Framework
        Application



                By VulcanMinds
What is the Play Framework BTW ?
                                                         Open Source Web
                                    So many more         framework written     Server-side
                                       things!              in Java/Scala  stateless or share-
                Full stack -                                                    nothing
                 Comes with                                                    framework
                  Compiler,                                                                  Probably created
                  Embedded                                                                  by frustrated Java
              server,Hibernate,L                                                               geeks tired of
              ogger,tTestrunner,                                                               complex Java
               Email,Template                                                                  Web App stack
                 engine,Scala
                ….that’s AHA!                                                                          Play is also ideal
                                                                                                       as a Dev platform
      Not too many
                                                                                                            with fast
       specs, over-
                                                                                                          incremental
    architected mess!
                                                                                                       features list dev
                                                                                                            life-cycle


     Sensible                                                                                              MVC stack with
  Convention                                                                                               great Template
  over miserable                                         Play Framework                                        Engine,
configurable XMLs                                                                                          Persistence and
                                                                                                          Testing engines.




    Great File-upload                                                                                  Cloud-aware and
        support                                                                                         NoSQL friendly



                                                                                                 Extremely
              Has lots of out-of-
                                                                                               convenient to
               the-box modules
                                                                                             write REST- JSON
              (as side-orders for
                                                                                             based middleware
               you if you need!)
                                                                                               functionality.
                                                          Renders well for         UTF-8 is the
                               Also integrates with CI
                               server like Calimoucho     Functional, Unit     gold standard in
                                                           Tests and well            Play.
                                                            suited with
                                                          Selenium based
                                                            GUI testing.
Why Play BTW?
•   Think over deeply and get your own answers

                                                                        Why use Play at all?
                                             Do you want one of the     Are you convinced?
                                             best designed state-of-       Are you sure?         Is your application a
                                                the-art stack for                                Web Application or a
                                                  building your                                       Web site?
                                                  applications?


                         Are you tired of the                                                                           How much is static
                        legacy Java stack for                                                                         content versus dynamic
                       web app development?                                                                                content ratio?




               Do you want to
              leverage the new
                Actors-based
            horizontally scalable,                                                                                             Do you want it fast and
          functional programming                                                                                               do you believe in TDD?
          advances to make your                                             Play Web
             app delight to your                                           Application
               developers and                                                Design
             responsive to your
             users/customers?
                    Dont you want to
                  exploit the new multi-                                                                                    Is your Application the
                   core asynchronous                                                                                         next killer-App or just
                 (threading) available in                                                                                   another moth that also
                 the intelligent chips for                                                                                    crawled the room?
                    performance and
                       throughput?
                                                                                                              Are you conventional
                                                                                                              RDBMS rookie or the
                                                                                                                 new generation
                                 Does your application                                                        NOSQL explorer who
                                  work in an Antarctic                                                        wants to scale out or
                                cave or a portable Data      Are your customers                                loose your wallet to
                                        center,                                       How does your Data      sharky and cannibal
                                                                  /employees
                                  sharing/supporting                                 look like and how you       RDBMS product
                                                            increasingly shouting
                                 Cloud authentication                                 are fore-seeing it to         pushers?
                                                              the BYOD slogan?
                                   and provisioning                                  grow? Will it morph or
                                                                (Browsers are
                                      protocols?                                    become fluid? Will your
                                                              morphing to every
                                                                                      App dev framework
                                                            shape and every size
                                                                                            support it?
                                                           and status=ubiquitous)
Play Framework App – Design considerations
                 finally!

      • Where is the features –list of your Application?
      • Next…Modularize .. You should be able to otherwise I doubt your
        intention to do a clean job!
      • Where is the use-cases list?
      • What your user base will use to access this app? Desktop browsers,
        handhelds and smart-phones, what else?
      • How many users will access ? 20-50 or 1K to 100K or 1M to 5 M? How
        many concurrent?
      • Security – want to go standalone or federated or cloud-ish like for e.g.
        OAuth,…blah blah blah?
      • Database NOSQL or SQL ? Take a tutorial/weekend course for getting
        started with NOSQL magic like MongoDB/Cassandra to make your future
        life easier if you haven’t done that already!
      • With SQL RDBMS consider using the built-in entity framework based
        wrapper APIs.
      • With NOSQL like MongoDB your schema is fluid like the morphing aliens
        in the movies. Enjoy the freedom!
      • Consider building a REST –JSON based app wrapper library to access
        your app functionality with any device. Your application’s taste is really
        the REST APIs that flavor it! Design it with artistic elegance!
Play Framework App – Design considerations
                 finally!
             • Designing Models.
               • Play supports Model objects that aren’t dumb! The model integrity
                 should be maintained by the model itself.
             • Designing Controllers
               • Segregate controllers by the functionality for easier maintenance
               • Chaining controllers is a bad idea.
               • Map methods to route URLs cleanly in REST-ful way consistently!
             • Designing Views
               • Use templates wisely to organize the bricks of your view content.
               • If using REST-ful API back-end and rich-front-end like JQuery/ Ext-JS or
                 you-name it …use the JSON speak to have a stateless conversation with
                 the back-end as much as possible. Use Ajax magic to exchange content
                 wherever user refuses to drink coffee waiting for it!
               • Use the inbuilt scheduler module to schedule jobs at startup or
                 otherwise.
               • Use available addon modules like GAE, PDF generator, MongoDB or
                 secure social like oauth1 / 2 , openID blah blah if needed.

Designing a play framework application

  • 1.
    Designing a PlayFramework Application By VulcanMinds
  • 2.
    What is thePlay Framework BTW ? Open Source Web So many more framework written Server-side things! in Java/Scala stateless or share- Full stack - nothing Comes with framework Compiler, Probably created Embedded by frustrated Java server,Hibernate,L geeks tired of ogger,tTestrunner, complex Java Email,Template Web App stack engine,Scala ….that’s AHA! Play is also ideal as a Dev platform Not too many with fast specs, over- incremental architected mess! features list dev life-cycle Sensible MVC stack with Convention  great Template over miserable Play Framework Engine, configurable XMLs Persistence and  Testing engines. Great File-upload Cloud-aware and support NoSQL friendly Extremely Has lots of out-of- convenient to the-box modules write REST- JSON (as side-orders for based middleware you if you need!) functionality. Renders well for UTF-8 is the Also integrates with CI server like Calimoucho Functional, Unit gold standard in Tests and well Play. suited with Selenium based GUI testing.
  • 3.
    Why Play BTW? • Think over deeply and get your own answers Why use Play at all? Do you want one of the Are you convinced? best designed state-of- Are you sure? Is your application a the-art stack for Web Application or a building your Web site? applications? Are you tired of the How much is static legacy Java stack for content versus dynamic web app development? content ratio? Do you want to leverage the new Actors-based horizontally scalable, Do you want it fast and functional programming do you believe in TDD? advances to make your Play Web app delight to your Application developers and Design responsive to your users/customers? Dont you want to exploit the new multi- Is your Application the core asynchronous next killer-App or just (threading) available in another moth that also the intelligent chips for crawled the room? performance and throughput? Are you conventional RDBMS rookie or the new generation Does your application NOSQL explorer who work in an Antarctic wants to scale out or cave or a portable Data Are your customers loose your wallet to center, How does your Data sharky and cannibal /employees sharing/supporting look like and how you RDBMS product increasingly shouting Cloud authentication are fore-seeing it to pushers? the BYOD slogan? and provisioning grow? Will it morph or (Browsers are protocols? become fluid? Will your morphing to every App dev framework shape and every size support it? and status=ubiquitous)
  • 4.
    Play Framework App– Design considerations finally! • Where is the features –list of your Application? • Next…Modularize .. You should be able to otherwise I doubt your intention to do a clean job! • Where is the use-cases list? • What your user base will use to access this app? Desktop browsers, handhelds and smart-phones, what else? • How many users will access ? 20-50 or 1K to 100K or 1M to 5 M? How many concurrent? • Security – want to go standalone or federated or cloud-ish like for e.g. OAuth,…blah blah blah? • Database NOSQL or SQL ? Take a tutorial/weekend course for getting started with NOSQL magic like MongoDB/Cassandra to make your future life easier if you haven’t done that already! • With SQL RDBMS consider using the built-in entity framework based wrapper APIs. • With NOSQL like MongoDB your schema is fluid like the morphing aliens in the movies. Enjoy the freedom! • Consider building a REST –JSON based app wrapper library to access your app functionality with any device. Your application’s taste is really the REST APIs that flavor it! Design it with artistic elegance!
  • 5.
    Play Framework App– Design considerations finally! • Designing Models. • Play supports Model objects that aren’t dumb! The model integrity should be maintained by the model itself. • Designing Controllers • Segregate controllers by the functionality for easier maintenance • Chaining controllers is a bad idea. • Map methods to route URLs cleanly in REST-ful way consistently! • Designing Views • Use templates wisely to organize the bricks of your view content. • If using REST-ful API back-end and rich-front-end like JQuery/ Ext-JS or you-name it …use the JSON speak to have a stateless conversation with the back-end as much as possible. Use Ajax magic to exchange content wherever user refuses to drink coffee waiting for it! • Use the inbuilt scheduler module to schedule jobs at startup or otherwise. • Use available addon modules like GAE, PDF generator, MongoDB or secure social like oauth1 / 2 , openID blah blah if needed.