web application frameworks (waf)
TRANSCRIPT
![Page 1: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/1.jpg)
Web Application Frameworks
(WAF)
Ako Kaman@scheperson
![Page 2: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/2.jpg)
What is a WAF?
• A general purpose software framework• Used to build:• Dynamic websites• Web applications• Web API
• Mostly based on MVC pattern• Push based (more popular)• Pull based
![Page 3: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/3.jpg)
Why should I bother using a WAF?
• Community support• Don’t reinvent the wheel• Better application structure• Decrease development time• Free tools and components (more on this later)• Hundreds of developers are smarter than your team! (RoR
=> 3477)
![Page 4: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/4.jpg)
What is included in a typical WAF?
• Asset management (some WAFs)• Generating sprites• Pre-compiling assets for production• Compiling SASS, Less and Coffescript on the fly (development)
• Helpers• Security• Local authentication• Using OAuth
• Controllers• Test tools
![Page 5: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/5.jpg)
What is included in a typical WAF? (cont.)
• Scaffolding• Command line tools• I18n and L10n support• Templating engine (View layer)• Routing and URL mapping (no
Default.aspx)!• Database access and abstraction (Model
layer)• Migrations• Caching data• Databased agnostic• Object oriented database access (ORM)
![Page 6: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/6.jpg)
How does MVC work?
Router
Controller Model
Browser
View
Request
Dispatch
Fetch dataPush data
Render Response
![Page 7: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/7.jpg)
Some WAFs out there
• PHP• Yii• Laravel• FuelPHP• CakePHP• Zend Framework• CodeIgniter (dead) => ExpressionEngine• Symfony => Yahoo Bookmarks, Delicious, DailyMotion
• Python• Flask• Pylons• Django => Pinterest, Disqus, Instagram, Mozilla, Rdio
![Page 8: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/8.jpg)
Some WAFs out there (cont.)
• Java/Scala• Lift => FourSquare• Play => LinkedIn, Klout, The Guardian
• Java• Grails• Spring
• ASP.NET (C#, VB) :(• ASP.NET MVC
• Ruby :)• Sinatra => Apple, BBC, Heroku• Ruby on Rails =>Twitter, GitHub, Basecamp, Groupon, SoundCloud
![Page 9: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/9.jpg)
![Page 10: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/10.jpg)
How does MVC work?
Router
Controller Model
Browser
View
Request
Dispatch
Fetch dataPush data
Render Response
![Page 11: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/11.jpg)
Making an HTTP request
Router
Controller Model
Browser
View
Request
Dispatch
Fetch dataPush data
Render Response
![Page 12: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/12.jpg)
Making an HTTP request (cont.)
http://example.com/books/1
GET /books/1 HTTP/1.1Host: example.com
![Page 13: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/13.jpg)
Routing and URL mapping
Router
Controller Model
Browser
View
Request
Dispatch
Fetch dataPush data
Render Response
![Page 14: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/14.jpg)
Routing and URL mapping (cont.)
get “admin/news”
match "admin/news", to: "admin#posts", as: "manage_news", via: :get
Prefix Verb URI Pattern Controller#Action
admin_news GET /admin/news admin#news
Prefix Verb URI Pattern Controller#Action
manage_news GET /admin/news admin#posts
![Page 15: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/15.jpg)
Routing and URL mapping (cont.)
resources “books”
Note the :id parameter
Prefix Verb URI Pattern Controller#Action
books GET /books books#index
POST /books books#create
new_book GET /books/new books#new
edit_book GET /books/:id/edit books#edit
book GET /books/:id books#show
PATCH /books/:id books#update
PUT /books/:id books#update
DELETE /books/:id books#destroy
![Page 16: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/16.jpg)
Migrations, Models and Controllers
Router
Controller Model
Browser
View
Request
Dispatch
Fetch dataPush data
Render Response
![Page 17: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/17.jpg)
Migrations, Models and Controllers (cont.)
class CreateBooks < ActiveRecord::Migration def change create_table :books do |t| t.string :title t.string :isbn t.integer :pages end endend
$ rails g migration CreateBooks title isbn pages:integer
What is a migration?
![Page 18: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/18.jpg)
Migrations, Models and Controllers (cont.)
class BooksController < ApplicationController ... def show @book = Book.find(params[:id]) # /books/:id end ...end
class Book < ActiveRecord::Baseend
![Page 19: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/19.jpg)
Views
Router
Controller Model
Browser
View
Request
Dispatch
Fetch dataPush data
Render Response
![Page 20: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/20.jpg)
Views (cont.)
<p> <strong>Title:</strong> <%= @book.title %></p><p> <strong>ISBN:</strong> <%= @book.isbn %></p><p> <strong>Pages:</strong> <%= @book.pages %></p>
<%= link_to 'Edit', edit_book_path(@book) %> |<%= link_to 'Back', books_path %>
![Page 21: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/21.jpg)
Views (cont.)
<p> <strong>Title:</strong> <%= @book.title %></p><p> <strong>ISBN:</strong> <%= @book.isbn %></p><p> <strong>Pages:</strong> <%= @book.pages %></p>
<%= link_to 'Edit', edit_book_path(@book) %> |<%= link_to 'Back', books_path %>
Prefix Verb URI Pattern Controller#Action
books GET /books books#index
edit_book GET /books/:id/edit books#edit
![Page 22: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/22.jpg)
The end result
![Page 23: Web Application Frameworks (WAF)](https://reader036.vdocuments.net/reader036/viewer/2022081504/554f38f4b4c905471e8b4895/html5/thumbnails/23.jpg)
Questions?