23
Web Application Frameworks (WAF) Ako Kaman @scheperson

Web Application Frameworks (WAF)

Embed Size (px)

Citation preview

Page 1: Web Application Frameworks (WAF)

Web Application Frameworks

(WAF)

Ako Kaman@scheperson

Page 2: Web Application Frameworks (WAF)

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)

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)

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)

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)

How does MVC work?

Router

Controller Model

Browser

View

Request

Dispatch

Fetch dataPush data

Render Response

Page 7: Web Application Frameworks (WAF)

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)

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)
Page 10: Web Application Frameworks (WAF)

How does MVC work?

Router

Controller Model

Browser

View

Request

Dispatch

Fetch dataPush data

Render Response

Page 11: Web Application Frameworks (WAF)

Making an HTTP request

Router

Controller Model

Browser

View

Request

Dispatch

Fetch dataPush data

Render Response

Page 12: Web Application Frameworks (WAF)

Making an HTTP request (cont.)

http://example.com/books/1

GET /books/1 HTTP/1.1Host: example.com

Page 13: Web Application Frameworks (WAF)

Routing and URL mapping

Router

Controller Model

Browser

View

Request

Dispatch

Fetch dataPush data

Render Response

Page 14: Web Application Frameworks (WAF)

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)

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)

Migrations, Models and Controllers

Router

Controller Model

Browser

View

Request

Dispatch

Fetch dataPush data

Render Response

Page 17: Web Application Frameworks (WAF)

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)

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)

Views

Router

Controller Model

Browser

View

Request

Dispatch

Fetch dataPush data

Render Response

Page 20: Web Application Frameworks (WAF)

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)

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)

The end result

Page 23: Web Application Frameworks (WAF)

Questions?