SlideShare una empresa de Scribd logo
1 de 188
Descargar para leer sin conexión
Tuesday, December 15, 2009
Ruby on Rails
Tuesday, December 15, 2009
AkitaOnRails.com
                slideshare.net/akitaonrails




Tuesday, December 15, 2009
Tuesday, December 15, 2009
> 100 slides
                              < 1 hora


Tuesday, December 15, 2009
www.slideshare.net/akitaonrails

                             fabio.akita@locaweb.com.br




Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Ruby on Rails             2.3

                         Ruby   1.8

        “Novo” Ruby             1.9
Tuesday, December 15, 2009
Ruby on Rails             2.3

                         Ruby   1.8

        “Novo” Ruby             1.9
Tuesday, December 15, 2009
Ruby on Rails             2.3

                         Ruby   1.8

        “Novo” Ruby             1.9
Tuesday, December 15, 2009
“Matz”




                             1993
Tuesday, December 15, 2009
Tuesday, December 15, 2009
“Prag Dave”




                             2001
Tuesday, December 15, 2009
Tuesday, December 15, 2009
“DHH”


                              2004
Tuesday, December 15, 2009
Tuesday, December 15, 2009
07/2004   0.5
                             12/2005   1.0
                             03/2006   1.1
                             01/2007   1.2
                             12/2007   2.0
                             06/2008   2.1
                             11/2008   2.2
                             03/2009   2.3
                             2009?     3.0

Tuesday, December 15, 2009
Tuesday, December 15, 2009
Charles Nutter



                                2006
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
“Tornar as coisas
                simples fáceis e as
                coisas complexas
                    possíveis”
                             Filoso a Ruby

Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Orientação a
                              Objetos?


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Alan Kay   Dan Ingalls
Tuesday, December 15, 2009
Alan Kay
Tuesday, December 15, 2009
Alan Kay
Tuesday, December 15, 2009
Eu inventei o termo
                                            ‘orientação a
                                          objetos’, e posso
                                         lhes dizer que não
                                        estava pensando em
                                                 C++


                             Alan Kay
Tuesday, December 15, 2009
Meta-
                        programação


Tuesday, December 15, 2009
Meta-
                        apresentação


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Ruby on Rails


Tuesday, December 15, 2009
Código que gera Código

          Convention over Con guration

                             Don’t Repeat Yourself

                        Extreme Programming
Tuesday, December 15, 2009
Código que gera Código

          Convention over Con guration

                             Don’t Repeat Yourself

                        Extreme Programming
Tuesday, December 15, 2009
Código que gera Código

          Convention over Con guration

                             Don’t Repeat Yourself

                        Extreme Programming
Tuesday, December 15, 2009
Código que gera Código

          Convention over Con guration

                             Don’t Repeat Yourself

                        Extreme Programming
Tuesday, December 15, 2009
Restful Resources

                    Unicode, Time Zone, i18n

        Segurança (XSS, CSRF, Injection)

              Rack Support (Middlewares)
Tuesday, December 15, 2009
Restful Resources

                    Unicode, Time Zone, i18n

        Segurança (XSS, CSRF, Injection)

              Rack Support (Middlewares)
Tuesday, December 15, 2009
Restful Resources

                    Unicode, Time Zone, i18n

        Segurança (XSS, CSRF, Injection)

              Rack Support (Middlewares)
Tuesday, December 15, 2009
Restful Resources

                    Unicode, Time Zone, i18n

        Segurança (XSS, CSRF, Injection)

              Rack Support (Middlewares)
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent => :destroy
      has_many :images, :as => :viewable, :order => :position,
        :dependent => :destroy
      has_many :properties, :through => :product_properties
      belongs_to :tax_category

      validates_presence_of :name
      validates_presence_of :master_price
      validates_presence_of :description

    make_permalink :with => :name, :field => :permalink
  end




Tuesday, December 15, 2009
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent => :destroy
      has_many :images, :as => :viewable, :order => :position,
        :dependent => :destroy
      has_many :properties, :through => :product_properties
      belongs_to :tax_category

      validates_presence_of :name
      validates_presence_of :master_price
      validates_presence_of :description

    make_permalink :with => :name, :field => :permalink
  end




Tuesday, December 15, 2009
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent => :destroy
      has_many :images, :as => :viewable, :order => :position,
        :dependent => :destroy
      has_many :properties, :through => :product_properties
      belongs_to :tax_category

      validates_presence_of :name
      validates_presence_of :master_price
      validates_presence_of :description

    make_permalink :with => :name, :field => :permalink
  end




Tuesday, December 15, 2009
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent => :destroy
      has_many :images, :as => :viewable, :order => :position,
        :dependent => :destroy
      has_many :properties, :through => :product_properties
      belongs_to :tax_category

      validates_presence_of :name
      validates_presence_of :master_price
      validates_presence_of :description

    make_permalink :with => :name, :field => :permalink
  end




Tuesday, December 15, 2009
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent => :destroy
      has_many :images, :as => :viewable, :order => :position,
        :dependent => :destroy
      has_many :properties, :through => :product_properties
      belongs_to :tax_category

      validates_presence_of :name
      validates_presence_of :master_price
      validates_presence_of :description

    make_permalink :with => :name, :field => :permalink
  end




Tuesday, December 15, 2009
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent => :destroy
      has_many :images, :as => :viewable, :order => :position,
        :dependent => :destroy
      has_many :properties, :through => :product_properties
      belongs_to :tax_category

      validates_presence_of :name
      validates_presence_of :master_price
      validates_presence_of :description

    make_permalink :with => :name, :field => :permalink
  end




Tuesday, December 15, 2009
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent => :destroy
      has_many :images, :as => :viewable, :order => :position,
        :dependent => :destroy
      has_many :properties, :through => :product_properties
      belongs_to :tax_category

      validates_presence_of :name
      validates_presence_of :master_price
      validates_presence_of :description

    make_permalink :with => :name, :field => :permalink
  end




Tuesday, December 15, 2009
Views ERB
  <div id="product-listing">
    <%= breadcrumbs(@taxon) %>
    <br/>
    <%= render :partial => "shared/products.html.erb",
    :locals => {:products => @products, :taxon => @taxon } %>
  </div>

  <% content_for :sidebar do %>
    <td id="shop-by-col" valign="top">
      <%= render :partial => "shared/taxonomies" %>
    </td>
  <% end %>

  <%= render :partial => 'shared/paginate',
    :locals => {:collection => @products, :options => {}}
    unless @products.empty? %>



Tuesday, December 15, 2009
Views ERB
  <div id="product-listing">
    <%= breadcrumbs(@taxon) %>
    <br/>
    <%= render :partial => "shared/products.html.erb",
    :locals => {:products => @products, :taxon => @taxon } %>
  </div>

  <% content_for :sidebar do %>
    <td id="shop-by-col" valign="top">
      <%= render :partial => "shared/taxonomies" %>
    </td>
  <% end %>

  <%= render :partial => 'shared/paginate',
    :locals => {:collection => @products, :options => {}}
    unless @products.empty? %>



Tuesday, December 15, 2009
Views ERB
  <div id="product-listing">
    <%= breadcrumbs(@taxon) %>
    <br/>
    <%= render :partial => "shared/products.html.erb",
    :locals => {:products => @products, :taxon => @taxon } %>
  </div>

  <% content_for :sidebar do %>
    <td id="shop-by-col" valign="top">
      <%= render :partial => "shared/taxonomies" %>
    </td>
  <% end %>

  <%= render :partial => 'shared/paginate',
    :locals => {:collection => @products, :options => {}}
    unless @products.empty? %>



Tuesday, December 15, 2009
Rotas RESTFul


  ActionController::Routing::Routes.draw do |map|

      map.resources :products
      map.resources :addresses
      map.resources :orders,     :has_many => [:line_items]

    map.namespace :admin do |admin|
      admin.resources :users
      admin.resources :products
    end
  end




Tuesday, December 15, 2009
Rotas RESTFul


  ActionController::Routing::Routes.draw do |map|

      map.resources :products
      map.resources :addresses
      map.resources :orders,     :has_many => [:line_items]

    map.namespace :admin do |admin|
      admin.resources :users
      admin.resources :products
    end
  end




Tuesday, December 15, 2009
Rotas RESTFul


  ActionController::Routing::Routes.draw do |map|

      map.resources :products
      map.resources :addresses
      map.resources :orders,     :has_many => [:line_items]

    map.namespace :admin do |admin|
      admin.resources :users
      admin.resources :products
    end
  end




Tuesday, December 15, 2009
Rotas RESTFul


  ActionController::Routing::Routes.draw do |map|

      map.resources :products
      map.resources :addresses
      map.resources :orders,     :has_many => [:line_items]

    map.namespace :admin do |admin|
      admin.resources :users
      admin.resources :products
    end
  end




Tuesday, December 15, 2009
Rotas RESTFul

                 GET /products/new
  ActionController::Routing::Routes.draw do |map|
                 GET /products
    map.resourcesPOST /products
                  :products
    map.resources :addresses
    map.resourcesGET /products/1 => [:line_items]
                  :orders,    :has_many

    map.namespaceGET /products/1/edit
                  :admin do |admin|
      admin.resources :users
                 PUT /products/1
      admin.resources :products
    end          DESTROY /products/1
  end




Tuesday, December 15, 2009
Controller
    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_extension_partials
      actions :all, :except => [:index, :destroy]

        show.before do
          @orders = Order.checkout_completed(true)
            .find_all_by_user_id(current_user.id)
        end

        create.after {       self.current_user = @user }

      create.response do |wants|
        wants.html { redirect_back_or_default(products_path) }
      end
    end


Tuesday, December 15, 2009
Controller
    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_extension_partials
      actions :all, :except => [:index, :destroy]

        show.before do
          @orders = Order.checkout_completed(true)
            .find_all_by_user_id(current_user.id)
        end

        create.after {       self.current_user = @user }

      create.response do |wants|
        wants.html { redirect_back_or_default(products_path) }
      end
    end


Tuesday, December 15, 2009
Controller
    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_extension_partials
      actions :all, :except => [:index, :destroy]

        show.before do
          @orders = Order.checkout_completed(true)
            .find_all_by_user_id(current_user.id)
        end

        create.after {       self.current_user = @user }

      create.response do |wants|
        wants.html { redirect_back_or_default(products_path) }
      end
    end


Tuesday, December 15, 2009
“Beautiful Code”


Tuesday, December 15, 2009
@Transient
                                                                 public BigDecimal getTotal()
      //$Id: Booking.java 5579 2007-06-27 00:06:49Z gavin $      {
      package org.jboss.seam.example.booking;                       return hotel.getPrice().multiply( new BigDecimal( getNights() ) );
                                                                 }
      import   java.io.Serializable;
      import   java.math.BigDecimal;                             @Transient
      import   java.text.DateFormat;                             public int getNights()
      import   java.util.Date;                                   {
                                                                    return (int) ( checkoutDate.getTime() - checkinDate.getTime() ) /
      import   javax.persistence.Basic;                       1000 / 60 / 60 / 24;
      import   javax.persistence.Entity;                         }
      import   javax.persistence.GeneratedValue;
      import   javax.persistence.Id;                             @Id @GeneratedValue
      import   javax.persistence.ManyToOne;                      public Long getId()
      import   javax.persistence.Temporal;                       {
      import   javax.persistence.TemporalType;                      return id;
      import   javax.persistence.Transient;                      }
                                                                 public void setId(Long id)
      import   org.hibernate.validator.Length;                   {
      import   org.hibernate.validator.NotNull;                     this.id = id;
      import   org.hibernate.validator.Pattern;                  }
      import   org.jboss.seam.annotations.Name;
                                                                 @NotNull
      @Entity                                                    @Basic @Temporal(TemporalType.DATE)
      @Name("booking")                                           public Date getCheckinDate()
      public class Booking implements Serializable               {
      {                                                             return checkinDate;
         private Long id;                                        }
         private User user;                                      public void setCheckinDate(Date datetime)
         private Hotel hotel;                                    {
         private Date checkinDate;                                  this.checkinDate = datetime;
         private Date checkoutDate;                              }
         private String creditCard;
         private String creditCardName;                          @ManyToOne @NotNull
         private int creditCardExpiryMonth;                      public Hotel getHotel()
         private int creditCardExpiryYear;                       {
         private boolean smoking;                                   return hotel;
         private int beds;                                       }
                                                                 public void setHotel(Hotel hotel)
         public Booking() {}                                     {
                                                                    this.hotel = hotel;
         public Booking(Hotel hotel, User user)                  }
         {
            this.hotel = hotel;                                  @ManyToOne @NotNull
            this.user = user;                                    public User getUser()
         }                                                       {
                                                                    return user;
                                                                 }

Tuesday, December 15, 2009
public int getBeds()
  public void setUser(User user)
                                                                                  {
  {
                                                                                     return beds;
     this.user = user;
                                                                                  }
  }

                                                                                  public void setBeds(int beds)
  @Basic @Temporal(TemporalType.DATE)
                                                                                  {
  @NotNull
                                                                                     this.beds = beds;
  public Date getCheckoutDate()
                                                                                  }
  {
                                                                                  @NotNull(message="Credit card name is required")
     return checkoutDate;
                                                                                  @Length(min=3, max=70, message="Credit card name is required")
  }
                                                                                  public String getCreditCardName()
  public void setCheckoutDate(Date checkoutDate)
                                                                                  {
  {
                                                                                     return creditCardName;
     this.checkoutDate = checkoutDate;
                                                                                  }
  }

                                                                                  public void setCreditCardName(String creditCardName)
  @NotNull(message="Credit card number is required")
                                                                                  {
  @Length(min=16, max=16, message="Credit card number must 16 digits long")
                                                                                     this.creditCardName = creditCardName;
  @Pattern(regex="^d*$", message="Credit card number must be numeric")
                                                                                  }
  public String getCreditCard()
  {
                                                                                  public int getCreditCardExpiryMonth()
     return creditCard;
                                                                                  {
  }
                                                                                     return creditCardExpiryMonth;
                                                                                  }
  public void setCreditCard(String creditCard)
  {
                                                                                  public void setCreditCardExpiryMonth(int creditCardExpiryMonth)
     this.creditCard = creditCard;
                                                                                  {
  }
                                                                                     this.creditCardExpiryMonth = creditCardExpiryMonth;
                                                                                  }
  @Transient
  public String getDescription()
                                                                                  public int getCreditCardExpiryYear()
  {
                                                                                  {
     DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
                                                                                     return creditCardExpiryYear;
     return hotel==null ? null : hotel.getName() +
                                                                                  }
           ", " + df.format( getCheckinDate() ) +
           " to " + df.format( getCheckoutDate() );
                                                                                  public void setCreditCardExpiryYear(int creditCardExpiryYear)
  }
                                                                                  {
                                                                                     this.creditCardExpiryYear = creditCardExpiryYear;
  public boolean isSmoking()
                                                                                  }
  {
     return smoking;
                                                                                  @Override
  }
                                                                                  public String toString()
                                                                                  {
  public void setSmoking(boolean smoking)
                                                                                     return "Booking(" + user + ","+ hotel + ")";
  {
                                                                                  }
     this.smoking = smoking;
  }
                                                                              }


Tuesday, December 15, 2009
class Booking < ActiveRecord::Base
               belongs_to :hotel
               belongs_to :user
               validates_presence_of :hotel
               validates_presence_of :user
               validates_presence_of :credit_card
               validates_presence_of :credit_card_name
               validates_length_of :credit_card, :within => 16..16
               validates_format_of :credit_card, :with => /^d*$/
               validates_length_of :credit_card_name, :within => 3..70

                def total
                  hotel.price * nights
                end

                def nights
                  ((checkout_date - checkin_date) / 1.day).round
                end

               def to_s
                 "Booking(#{user},#{hotel})"
               end
             end
Tuesday, December 15, 2009
class Booking < ActiveRecord::Base
               belongs_to :hotel
               belongs_to :user
               validates_presence_of :hotel
               validates_presence_of :user
               validates_presence_of :credit_card
               validates_presence_of :credit_card_name
               validates_length_of :credit_card, :within => 16..16
               validates_format_of :credit_card, :with => /^d*$/
               validates_length_of :credit_card_name, :within => 3..70

                def total
                  hotel.price * nights
                end

                def nights
                  ((checkout_date - checkin_date) / 1.day).round
                end

               def to_s
                 "Booking(#{user},#{hotel})"
               end
             end
Tuesday, December 15, 2009
class CreateBookings < ActiveRecord::Migration
                        def self.up
                          create_table :bookings do |t|
                            t.references :user
                            t.references :hotel
                            t.datetime :checkin
                            t.datetime :checkout
                            t.string :credit_card
                            t.string :credit_card_name
                            t.integer :credit_card_expiry_month
                            t.integer :credit_card_expiry_year
                            t.boolean :smoking
                            t.integer :beds

                                 t.timestamps
                               end
                             end

                        def self.down
                          drop_table :bookings
                        end
                      end

Tuesday, December 15, 2009
class CreateBookings < ActiveRecord::Migration
                        def self.up
                          create_table :bookings do |t|
                            t.references :user
                            t.references :hotel
                            t.datetime :checkin
                            t.datetime :checkout
                            t.string :credit_card
                            t.string :credit_card_name
                            t.integer :credit_card_expiry_month
                            t.integer :credit_card_expiry_year
                            t.boolean :smoking
                            t.integer :beds

                                 t.timestamps
                               end
                             end

                        def self.down
                          drop_table :bookings
                        end
                      end

Tuesday, December 15, 2009
class CreateBookings < ActiveRecord::Migration
                        def self.up
                          create_table :bookings do |t|
                            t.references :user
                            t.references :hotel
                            t.datetime :checkin
                            t.datetime :checkout
                            t.string :credit_card
                            t.string :credit_card_name
                            t.integer :credit_card_expiry_month
                            t.integer :credit_card_expiry_year
                            t.boolean :smoking
                            t.integer :beds

                                 t.timestamps
                               end
                             end

                        def self.down
                          drop_table :bookings
                        end
                      end

Tuesday, December 15, 2009
190
                             vs
                             40


Tuesday, December 15, 2009
“Eles servem mais de 23 milhões de visitantes/mês. A conversão
             resultou em 20 mil linhas de Ruby em vez de 125 mil linhas de Java e,
              mais importante, facilitou a dificuldade que tinham em manutenção.
              Eles também finalizaram a reescrita do sistema em apenas 3 meses
              com 4 desenvolvedores. Uma vez completo e otimizado, o site deles
                                agora é mais rápido que antes.”




                             http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails




Tuesday, December 15, 2009
“Eles servem mais de 23 milhões de visitantes/mês. A conversão
             resultou em 20 mil linhas de Ruby em vez de 125 mil linhas de Java e,
              mais importante, facilitou a dificuldade que tinham em manutenção.
              Eles também finalizaram a reescrita do sistema em apenas 3 meses
              com 4 desenvolvedores. Uma vez completo e otimizado, o site deles
                                agora é mais rápido que antes.”




                             http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails




Tuesday, December 15, 2009
“Eles servem mais de 23 milhões de visitantes/mês. A conversão
             resultou em 20 mil linhas de Ruby em vez de 125 mil linhas de Java e,
              mais importante, facilitou a dificuldade que tinham em manutenção.
              Eles também finalizaram a reescrita do sistema em apenas 3 meses
              com 4 desenvolvedores. Uma vez completo e otimizado, o site deles
                                agora é mais rápido que antes.”




                             http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails




Tuesday, December 15, 2009
“Eles servem mais de 23 milhões de visitantes/mês. A conversão
             resultou em 20 mil linhas de Ruby em vez de 125 mil linhas de Java e,
              mais importante, facilitou a dificuldade que tinham em manutenção.
              Eles também finalizaram a reescrita do sistema em apenas 3 meses
              com 4 desenvolvedores. Uma vez completo e otimizado, o site deles
                                agora é mais rápido que antes.”




                             http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails




Tuesday, December 15, 2009
Ferramentas
                                Ágeis


Tuesday, December 15, 2009
Gitorious
       Repositórios
                                   Github
       Integração                 Integrity
       Contínua              Cruise Control
                                Capistrano
       Deployment
                                   Puppet

       Monitoramento             New Relic
Tuesday, December 15, 2009
Gitorious
       Repositórios
                                   Github
       Integração                 Integrity
       Contínua              Cruise Control
                                Capistrano
       Deployment
                                   Puppet

       Monitoramento             New Relic
Tuesday, December 15, 2009
Gitorious
       Repositórios
                                   Github
       Integração                 Integrity
       Contínua              Cruise Control
                                Capistrano
       Deployment
                                   Puppet

       Monitoramento             New Relic
Tuesday, December 15, 2009
Gitorious
       Repositórios
                                   Github
       Integração                 Integrity
       Contínua              Cruise Control
                                Capistrano
       Deployment
                                   Puppet

       Monitoramento             New Relic
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Comunidade


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
O que dizem
                               por aí ...


Tuesday, December 15, 2009
Pouco usado


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Rails não Escala


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Blaine Cook

                             http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter


Tuesday, December 15, 2009
Para colocar as coisas em
       perspectiva, o Friendster foi
         escrito em Java e eles
          mudaram para PHP.
         MySpace foi escrito em
       ColdFusion e eles mudaram
             para ASP.NET.




                                                                                  Blaine Cook

                             http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter


Tuesday, December 15, 2009
Para colocar as coisas em
       perspectiva, o Friendster foi
         escrito em Java e eles
          mudaram para PHP.
         MySpace foi escrito em
       ColdFusion e eles mudaram
             para ASP.NET.

     Quando as pessoas caem em
      problemas de escalabilidade,
       normalmente acham que a
     linguagem é o problema, mas
     eu acho que isso raramente é
             a realidade.                                                         Blaine Cook

                             http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter


Tuesday, December 15, 2009
“O The New York Times usou Ruby on Rails
                 para agregar, analizar e mostrar os
              resultados das eleições em quase tempo
             real em um de seus sites mais acessados
                        de todos os tempos.”


                     http://www.computerworld.com.au/article/268003/ruby_rails_rolls_into_enterprise?fp=16&fpid=1




Tuesday, December 15, 2009
“O The New York Times usou Ruby on Rails
                 para agregar, analizar e mostrar os
              resultados das eleições em quase tempo
             real em um de seus sites mais acessados
                        de todos os tempos.”


                     http://www.computerworld.com.au/article/268003/ruby_rails_rolls_into_enterprise?fp=16&fpid=1




Tuesday, December 15, 2009
Ruby é Lento


Tuesday, December 15, 2009
x mais lento que C++




Tuesday, December 15, 2009
x mais lento que C++


                      0      50            100           150   200

  Python 2


  Ruby 1.9


        Perl


      JRuby


   Python 3


        PHP


  Ruby 1.8.6




Tuesday, December 15, 2009
Homepage: 331 ms




Tuesday, December 15, 2009
Homepage: 331 ms

                             Total: 5.45 s

Tuesday, December 15, 2009
Tuesday, December 15, 2009
Performance
                           !=
                     Escalabilidade

Tuesday, December 15, 2009
Outros Mitos?


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Mais Produtivo

                              “Melhor”

                             Anti-legado
Tuesday, December 15, 2009
Sempre se Lembre




             Poderíamos contratar um Macaco Treinado
                     para fazer seu Trabalho!
Tuesday, December 15, 2009
Agilidade


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Robert C. Martin


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Código Limpo


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Test Driven
                        Development


Tuesday, December 15, 2009
Tuesday, December 15, 2009
describe BankAccount do
          before :each do
            @bank_account = BankAccount.new :balance => 250
          end

            it "should not be valid" do
              @bank_account.should be_valid
            end

          it "should transfer funds successfully" do
            @bank_account.should_receive(:transfer)
              .with_args(:amount => 100)
              .and_return(true)
            @bank_account.execute_transaction(:amount => 100)
            @bank_account.balance.should == 150
          end
        end


Tuesday, December 15, 2009
describe BankAccount do
          before :each do
            @bank_account = BankAccount.new :balance => 250
          end

            it "should not be valid" do
              @bank_account.should be_valid
            end

          it "should transfer funds successfully" do
            @bank_account.should_receive(:transfer)
              .with_args(:amount => 100)
              .and_return(true)
            @bank_account.execute_transaction(:amount => 100)
            @bank_account.balance.should == 150
          end
        end


Tuesday, December 15, 2009
describe BankAccount do
          before :each do
            @bank_account = BankAccount.new :balance => 250
          end

            it "should not be valid" do
              @bank_account.should be_valid
            end

          it "should transfer funds successfully" do
            @bank_account.should_receive(:transfer)
              .with_args(:amount => 100)
              .and_return(true)
            @bank_account.execute_transaction(:amount => 100)
            @bank_account.balance.should == 150
          end
        end


Tuesday, December 15, 2009
describe BankAccount do
          before :each do
            @bank_account = BankAccount.new :balance => 250
          end

            it "should not be valid" do
              @bank_account.should be_valid
            end

          it "should transfer funds successfully" do
            @bank_account.should_receive(:transfer)
              .with_args(:amount => 100)
              .and_return(true)
            @bank_account.execute_transaction(:amount => 100)
            @bank_account.balance.should == 150
          end
        end


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Funcionalidade: Adição
               Para evitar erros bobos
               Como um péssimo matemático
               Eu quero saber como somar dois números

                 Cenário: Adicionar dois números
                   Dado que eu digitei 50 na calculadora
                   E que eu digitei 70 na calculadora
                   Quando eu aperto o botão de soma
                   Então o resultado na calculadora deve ser 120




Tuesday, December 15, 2009
Funcionalidade: Adição
               Para evitar erros bobos
               Como um péssimo matemático
               Eu quero saber como somar dois números

                 Cenário: Adicionar dois números
                   Dado que eu digitei 50 na calculadora
                   E que eu digitei 70 na calculadora
                   Quando eu aperto o botão de soma
                   Então o resultado na calculadora deve ser 120




Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
Não é mais
                             demorado?


Tuesday, December 15, 2009
Produtividade
                             Cowboy    Profissional




Tuesday, December 15, 2009
Produtividade
                                  Cowboy                   Profissional

                70.00



                52.50
Produtividade




                35.00



                17.50



                   0
                        1     2     3      4           5          6      7   8
                                               Tempo
 Tuesday, December 15, 2009
Produtividade
                                  Cowboy                   Profissional

                70.00



                52.50
Produtividade




                35.00



                17.50



                   0
                        1     2     3      4           5          6      7   8
                                               Tempo
 Tuesday, December 15, 2009
Produtividade
                                  Cowboy                   Profissional

                70.00



                52.50
Produtividade




                35.00



                17.50



                   0
                        1     2     3      4           5          6      7   8
                                               Tempo
 Tuesday, December 15, 2009
Produtividade
                                  Cowboy                   Profissional

                70.00



                52.50
Produtividade




                35.00



                17.50



                   0
                        1     2     3      4           5          6      7   8
                                               Tempo
 Tuesday, December 15, 2009
Produtividade
                                  Cowboy                   Profissional

                70.00



                52.50
Produtividade




                35.00



                17.50



                   0
                        1     2     3      4           5          6      7   8
                                               Tempo
 Tuesday, December 15, 2009
Produtividade
                                  Cowboy                   Profissional

                70.00



                52.50
Produtividade




                35.00



                17.50



                   0
                        1     2     3      4           5          6      7   8
                                               Tempo
 Tuesday, December 15, 2009
Produtividade
                                  Cowboy                   Profissional

                70.00



                52.50
Produtividade




                35.00



                17.50



                   0
                        1     2     3      4           5          6      7   8
                                               Tempo
 Tuesday, December 15, 2009
Produtividade
                                  Cowboy                   Profissional

                70.00



                52.50
Produtividade




                35.00



                17.50



                   0
                        1     2     3      4           5          6      7   8
                                               Tempo
 Tuesday, December 15, 2009
Produtividade
                                  Cowboy                   Profissional

                70.00



                52.50
Produtividade




                35.00



                17.50



                   0
                        1     2     3      4           5          6      7   8
                                               Tempo
 Tuesday, December 15, 2009
Tuesday, December 15, 2009
Tuesday, December 15, 2009
237 Equipes
                   137 Finalizadas


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Empreendedorismo

                             Código e “Forma”

                     Ciclo de Vida de Projetos

                  Comunidade Open Source
Tuesday, December 15, 2009
Empreendedorismo

                             Código e “Forma”

                     Ciclo de Vida de Projetos

                  Comunidade Open Source
Tuesday, December 15, 2009
Empreendedorismo

                             Código e “Forma”

                     Ciclo de Vida de Projetos

                  Comunidade Open Source
Tuesday, December 15, 2009
Empreendedorismo

                             Código e “Forma”

                     Ciclo de Vida de Projetos

                  Comunidade Open Source
Tuesday, December 15, 2009
Post hoc ergo
                         propter hoc


Tuesday, December 15, 2009
Pro ssionalismo


Tuesday, December 15, 2009
Tuesday, December 15, 2009
Obrigado!
                              akitaonrails.com
                             railssummit.com.br



Tuesday, December 15, 2009

Más contenido relacionado

Similar a Semcomp de São Carlos

2009, o ano do Ruby on Rails no Brasil - CaelumDay 2009
2009, o ano do Ruby on Rails no Brasil - CaelumDay 20092009, o ano do Ruby on Rails no Brasil - CaelumDay 2009
2009, o ano do Ruby on Rails no Brasil - CaelumDay 2009
Caue Guerra
 

Similar a Semcomp de São Carlos (20)

Dev In Rio 2009
Dev In Rio 2009Dev In Rio 2009
Dev In Rio 2009
 
2009, o ano do Ruby on Rails no Brasil - CaelumDay 2009
2009, o ano do Ruby on Rails no Brasil - CaelumDay 20092009, o ano do Ruby on Rails no Brasil - CaelumDay 2009
2009, o ano do Ruby on Rails no Brasil - CaelumDay 2009
 
Business School de São Paulo 2009
Business School de São Paulo 2009Business School de São Paulo 2009
Business School de São Paulo 2009
 
Latinoware 2009
Latinoware 2009Latinoware 2009
Latinoware 2009
 
Software livre e padrões abertos no desenvolvimento Web
Software livre e padrões abertos no desenvolvimento WebSoftware livre e padrões abertos no desenvolvimento Web
Software livre e padrões abertos no desenvolvimento Web
 
Oxente on Rails 2009
Oxente on Rails 2009Oxente on Rails 2009
Oxente on Rails 2009
 
Rails Summit 2009
Rails Summit 2009Rails Summit 2009
Rails Summit 2009
 
2nd Annual Start-up Launches with Dr. Werner Vogels (SPOT101) | AWS re:Invent...
2nd Annual Start-up Launches with Dr. Werner Vogels (SPOT101) | AWS re:Invent...2nd Annual Start-up Launches with Dr. Werner Vogels (SPOT101) | AWS re:Invent...
2nd Annual Start-up Launches with Dr. Werner Vogels (SPOT101) | AWS re:Invent...
 
Chad Udell - Developers are from Mars, Designers are from Venus
Chad Udell - Developers are from Mars, Designers are from VenusChad Udell - Developers are from Mars, Designers are from Venus
Chad Udell - Developers are from Mars, Designers are from Venus
 
Telco: Voice-Command Personal Agent Service with AWS Cloud (MBL202) | AWS re:...
Telco: Voice-Command Personal Agent Service with AWS Cloud (MBL202) | AWS re:...Telco: Voice-Command Personal Agent Service with AWS Cloud (MBL202) | AWS re:...
Telco: Voice-Command Personal Agent Service with AWS Cloud (MBL202) | AWS re:...
 
100% JS
100% JS100% JS
100% JS
 
Cloudera Desktop
Cloudera DesktopCloudera Desktop
Cloudera Desktop
 
Diving Into the New AWS SDK for Ruby (TLS305) | AWS re:Invent 2013
Diving Into the New AWS SDK for Ruby (TLS305) | AWS re:Invent 2013Diving Into the New AWS SDK for Ruby (TLS305) | AWS re:Invent 2013
Diving Into the New AWS SDK for Ruby (TLS305) | AWS re:Invent 2013
 
Cross platform development
Cross platform developmentCross platform development
Cross platform development
 
Encontro Ágil
Encontro ÁgilEncontro Ágil
Encontro Ágil
 
Is Agile The New Waterfall
Is Agile The New WaterfallIs Agile The New Waterfall
Is Agile The New Waterfall
 
Ten Trends
Ten TrendsTen Trends
Ten Trends
 
Angrybirds - Overview for a High Performance Shop
Angrybirds - Overview for a High Performance ShopAngrybirds - Overview for a High Performance Shop
Angrybirds - Overview for a High Performance Shop
 
Of Rats And Dragons
Of Rats And DragonsOf Rats And Dragons
Of Rats And Dragons
 
Atlassian - A Different Kind Of Software Company
Atlassian - A Different Kind Of Software CompanyAtlassian - A Different Kind Of Software Company
Atlassian - A Different Kind Of Software Company
 

Más de Fabio Akita

Más de Fabio Akita (20)

Devconf 2019 - São Carlos
Devconf 2019 - São CarlosDevconf 2019 - São Carlos
Devconf 2019 - São Carlos
 
Meetup Nerdzão - English Talk about Languages
Meetup Nerdzão  - English Talk about LanguagesMeetup Nerdzão  - English Talk about Languages
Meetup Nerdzão - English Talk about Languages
 
Desmistificando Blockchains p/ Developers - Criciuma Dev Conf 2018
Desmistificando Blockchains p/ Developers - Criciuma Dev Conf 2018Desmistificando Blockchains p/ Developers - Criciuma Dev Conf 2018
Desmistificando Blockchains p/ Developers - Criciuma Dev Conf 2018
 
Desmistificando Blockchains - 20o Encontro Locaweb SP
Desmistificando Blockchains - 20o Encontro Locaweb SPDesmistificando Blockchains - 20o Encontro Locaweb SP
Desmistificando Blockchains - 20o Encontro Locaweb SP
 
Desmistificando Blockchains - Insiter Goiania
Desmistificando Blockchains - Insiter GoianiaDesmistificando Blockchains - Insiter Goiania
Desmistificando Blockchains - Insiter Goiania
 
Blockchain em 7 minutos - 7Masters
Blockchain em 7 minutos - 7MastersBlockchain em 7 minutos - 7Masters
Blockchain em 7 minutos - 7Masters
 
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
Elixir  -Tolerância a Falhas para Adultos - GDG CampinasElixir  -Tolerância a Falhas para Adultos - GDG Campinas
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
 
Desmistificando Mitos de Tech Startups - Intercon 2017
Desmistificando Mitos de Tech Startups - Intercon 2017Desmistificando Mitos de Tech Startups - Intercon 2017
Desmistificando Mitos de Tech Startups - Intercon 2017
 
30 Days to Elixir and Crystal and Back to Ruby
30 Days to Elixir and Crystal and Back to Ruby30 Days to Elixir and Crystal and Back to Ruby
30 Days to Elixir and Crystal and Back to Ruby
 
Uma Discussão sobre a Carreira de TI
Uma Discussão sobre a Carreira de TIUma Discussão sobre a Carreira de TI
Uma Discussão sobre a Carreira de TI
 
THE CONF - Opening Keynote
THE CONF - Opening KeynoteTHE CONF - Opening Keynote
THE CONF - Opening Keynote
 
A Journey through New Languages - Rancho Dev 2017
A Journey through New Languages - Rancho Dev 2017A Journey through New Languages - Rancho Dev 2017
A Journey through New Languages - Rancho Dev 2017
 
Desmistificando Mitos de Startups - Sebrae - AP
Desmistificando Mitos de Startups - Sebrae - APDesmistificando Mitos de Startups - Sebrae - AP
Desmistificando Mitos de Startups - Sebrae - AP
 
A Journey through New Languages - Guru Sorocaba 2017
A Journey through New Languages - Guru Sorocaba 2017A Journey through New Languages - Guru Sorocaba 2017
A Journey through New Languages - Guru Sorocaba 2017
 
A Journey through New Languages - Insiter 2017
A Journey through New Languages - Insiter 2017A Journey through New Languages - Insiter 2017
A Journey through New Languages - Insiter 2017
 
A Journey through New Languages - Locaweb Tech Day
A Journey through New Languages - Locaweb Tech DayA Journey through New Languages - Locaweb Tech Day
A Journey through New Languages - Locaweb Tech Day
 
A Journey through new Languages - Intercon 2016
A Journey through new Languages - Intercon 2016A Journey through new Languages - Intercon 2016
A Journey through new Languages - Intercon 2016
 
Premature Optimization 2.0 - Intercon 2016
Premature Optimization 2.0 - Intercon 2016Premature Optimization 2.0 - Intercon 2016
Premature Optimization 2.0 - Intercon 2016
 
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização PrematuraConexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
 
The Open Commerce Conference - Premature Optimisation: The Root of All Evil
The Open Commerce Conference - Premature Optimisation: The Root of All EvilThe Open Commerce Conference - Premature Optimisation: The Root of All Evil
The Open Commerce Conference - Premature Optimisation: The Root of All Evil
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Semcomp de São Carlos

  • 2. Ruby on Rails Tuesday, December 15, 2009
  • 3. AkitaOnRails.com slideshare.net/akitaonrails Tuesday, December 15, 2009
  • 5. > 100 slides < 1 hora Tuesday, December 15, 2009
  • 6. www.slideshare.net/akitaonrails fabio.akita@locaweb.com.br Tuesday, December 15, 2009
  • 10. Ruby on Rails 2.3 Ruby 1.8 “Novo” Ruby 1.9 Tuesday, December 15, 2009
  • 11. Ruby on Rails 2.3 Ruby 1.8 “Novo” Ruby 1.9 Tuesday, December 15, 2009
  • 12. Ruby on Rails 2.3 Ruby 1.8 “Novo” Ruby 1.9 Tuesday, December 15, 2009
  • 13. “Matz” 1993 Tuesday, December 15, 2009
  • 15. “Prag Dave” 2001 Tuesday, December 15, 2009
  • 17. “DHH” 2004 Tuesday, December 15, 2009
  • 19. 07/2004 0.5 12/2005 1.0 03/2006 1.1 01/2007 1.2 12/2007 2.0 06/2008 2.1 11/2008 2.2 03/2009 2.3 2009? 3.0 Tuesday, December 15, 2009
  • 21. Charles Nutter 2006 Tuesday, December 15, 2009
  • 26. “Tornar as coisas simples fáceis e as coisas complexas possíveis” Filoso a Ruby Tuesday, December 15, 2009
  • 31. Orientação a Objetos? Tuesday, December 15, 2009
  • 33. Alan Kay Dan Ingalls Tuesday, December 15, 2009
  • 36. Eu inventei o termo ‘orientação a objetos’, e posso lhes dizer que não estava pensando em C++ Alan Kay Tuesday, December 15, 2009
  • 37. Meta- programação Tuesday, December 15, 2009
  • 38. Meta- apresentação Tuesday, December 15, 2009
  • 40. Ruby on Rails Tuesday, December 15, 2009
  • 41. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Tuesday, December 15, 2009
  • 42. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Tuesday, December 15, 2009
  • 43. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Tuesday, December 15, 2009
  • 44. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Tuesday, December 15, 2009
  • 45. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Rack Support (Middlewares) Tuesday, December 15, 2009
  • 46. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Rack Support (Middlewares) Tuesday, December 15, 2009
  • 47. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Rack Support (Middlewares) Tuesday, December 15, 2009
  • 48. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Rack Support (Middlewares) Tuesday, December 15, 2009
  • 63. Model class Product < ActiveRecord::Base after_create :set_initial_inventory has_many :variants, :dependent => :destroy has_many :images, :as => :viewable, :order => :position, :dependent => :destroy has_many :properties, :through => :product_properties belongs_to :tax_category validates_presence_of :name validates_presence_of :master_price validates_presence_of :description make_permalink :with => :name, :field => :permalink end Tuesday, December 15, 2009
  • 64. Model class Product < ActiveRecord::Base after_create :set_initial_inventory has_many :variants, :dependent => :destroy has_many :images, :as => :viewable, :order => :position, :dependent => :destroy has_many :properties, :through => :product_properties belongs_to :tax_category validates_presence_of :name validates_presence_of :master_price validates_presence_of :description make_permalink :with => :name, :field => :permalink end Tuesday, December 15, 2009
  • 65. Model class Product < ActiveRecord::Base after_create :set_initial_inventory has_many :variants, :dependent => :destroy has_many :images, :as => :viewable, :order => :position, :dependent => :destroy has_many :properties, :through => :product_properties belongs_to :tax_category validates_presence_of :name validates_presence_of :master_price validates_presence_of :description make_permalink :with => :name, :field => :permalink end Tuesday, December 15, 2009
  • 66. Model class Product < ActiveRecord::Base after_create :set_initial_inventory has_many :variants, :dependent => :destroy has_many :images, :as => :viewable, :order => :position, :dependent => :destroy has_many :properties, :through => :product_properties belongs_to :tax_category validates_presence_of :name validates_presence_of :master_price validates_presence_of :description make_permalink :with => :name, :field => :permalink end Tuesday, December 15, 2009
  • 67. Model class Product < ActiveRecord::Base after_create :set_initial_inventory has_many :variants, :dependent => :destroy has_many :images, :as => :viewable, :order => :position, :dependent => :destroy has_many :properties, :through => :product_properties belongs_to :tax_category validates_presence_of :name validates_presence_of :master_price validates_presence_of :description make_permalink :with => :name, :field => :permalink end Tuesday, December 15, 2009
  • 68. Model class Product < ActiveRecord::Base after_create :set_initial_inventory has_many :variants, :dependent => :destroy has_many :images, :as => :viewable, :order => :position, :dependent => :destroy has_many :properties, :through => :product_properties belongs_to :tax_category validates_presence_of :name validates_presence_of :master_price validates_presence_of :description make_permalink :with => :name, :field => :permalink end Tuesday, December 15, 2009
  • 69. Model class Product < ActiveRecord::Base after_create :set_initial_inventory has_many :variants, :dependent => :destroy has_many :images, :as => :viewable, :order => :position, :dependent => :destroy has_many :properties, :through => :product_properties belongs_to :tax_category validates_presence_of :name validates_presence_of :master_price validates_presence_of :description make_permalink :with => :name, :field => :permalink end Tuesday, December 15, 2009
  • 70. Views ERB <div id="product-listing"> <%= breadcrumbs(@taxon) %> <br/> <%= render :partial => "shared/products.html.erb", :locals => {:products => @products, :taxon => @taxon } %> </div> <% content_for :sidebar do %> <td id="shop-by-col" valign="top"> <%= render :partial => "shared/taxonomies" %> </td> <% end %> <%= render :partial => 'shared/paginate', :locals => {:collection => @products, :options => {}} unless @products.empty? %> Tuesday, December 15, 2009
  • 71. Views ERB <div id="product-listing"> <%= breadcrumbs(@taxon) %> <br/> <%= render :partial => "shared/products.html.erb", :locals => {:products => @products, :taxon => @taxon } %> </div> <% content_for :sidebar do %> <td id="shop-by-col" valign="top"> <%= render :partial => "shared/taxonomies" %> </td> <% end %> <%= render :partial => 'shared/paginate', :locals => {:collection => @products, :options => {}} unless @products.empty? %> Tuesday, December 15, 2009
  • 72. Views ERB <div id="product-listing"> <%= breadcrumbs(@taxon) %> <br/> <%= render :partial => "shared/products.html.erb", :locals => {:products => @products, :taxon => @taxon } %> </div> <% content_for :sidebar do %> <td id="shop-by-col" valign="top"> <%= render :partial => "shared/taxonomies" %> </td> <% end %> <%= render :partial => 'shared/paginate', :locals => {:collection => @products, :options => {}} unless @products.empty? %> Tuesday, December 15, 2009
  • 73. Rotas RESTFul ActionController::Routing::Routes.draw do |map| map.resources :products map.resources :addresses map.resources :orders, :has_many => [:line_items] map.namespace :admin do |admin| admin.resources :users admin.resources :products end end Tuesday, December 15, 2009
  • 74. Rotas RESTFul ActionController::Routing::Routes.draw do |map| map.resources :products map.resources :addresses map.resources :orders, :has_many => [:line_items] map.namespace :admin do |admin| admin.resources :users admin.resources :products end end Tuesday, December 15, 2009
  • 75. Rotas RESTFul ActionController::Routing::Routes.draw do |map| map.resources :products map.resources :addresses map.resources :orders, :has_many => [:line_items] map.namespace :admin do |admin| admin.resources :users admin.resources :products end end Tuesday, December 15, 2009
  • 76. Rotas RESTFul ActionController::Routing::Routes.draw do |map| map.resources :products map.resources :addresses map.resources :orders, :has_many => [:line_items] map.namespace :admin do |admin| admin.resources :users admin.resources :products end end Tuesday, December 15, 2009
  • 77. Rotas RESTFul GET /products/new ActionController::Routing::Routes.draw do |map| GET /products map.resourcesPOST /products :products map.resources :addresses map.resourcesGET /products/1 => [:line_items] :orders, :has_many map.namespaceGET /products/1/edit :admin do |admin| admin.resources :users PUT /products/1 admin.resources :products end DESTROY /products/1 end Tuesday, December 15, 2009
  • 78. Controller class UsersController < Spree::BaseController resource_controller before_filter :initialize_extension_partials actions :all, :except => [:index, :destroy] show.before do @orders = Order.checkout_completed(true) .find_all_by_user_id(current_user.id) end create.after { self.current_user = @user } create.response do |wants| wants.html { redirect_back_or_default(products_path) } end end Tuesday, December 15, 2009
  • 79. Controller class UsersController < Spree::BaseController resource_controller before_filter :initialize_extension_partials actions :all, :except => [:index, :destroy] show.before do @orders = Order.checkout_completed(true) .find_all_by_user_id(current_user.id) end create.after { self.current_user = @user } create.response do |wants| wants.html { redirect_back_or_default(products_path) } end end Tuesday, December 15, 2009
  • 80. Controller class UsersController < Spree::BaseController resource_controller before_filter :initialize_extension_partials actions :all, :except => [:index, :destroy] show.before do @orders = Order.checkout_completed(true) .find_all_by_user_id(current_user.id) end create.after { self.current_user = @user } create.response do |wants| wants.html { redirect_back_or_default(products_path) } end end Tuesday, December 15, 2009
  • 82. @Transient public BigDecimal getTotal() //$Id: Booking.java 5579 2007-06-27 00:06:49Z gavin $ { package org.jboss.seam.example.booking; return hotel.getPrice().multiply( new BigDecimal( getNights() ) ); } import java.io.Serializable; import java.math.BigDecimal; @Transient import java.text.DateFormat; public int getNights() import java.util.Date; { return (int) ( checkoutDate.getTime() - checkinDate.getTime() ) / import javax.persistence.Basic; 1000 / 60 / 60 / 24; import javax.persistence.Entity; } import javax.persistence.GeneratedValue; import javax.persistence.Id; @Id @GeneratedValue import javax.persistence.ManyToOne; public Long getId() import javax.persistence.Temporal; { import javax.persistence.TemporalType; return id; import javax.persistence.Transient; } public void setId(Long id) import org.hibernate.validator.Length; { import org.hibernate.validator.NotNull; this.id = id; import org.hibernate.validator.Pattern; } import org.jboss.seam.annotations.Name; @NotNull @Entity @Basic @Temporal(TemporalType.DATE) @Name("booking") public Date getCheckinDate() public class Booking implements Serializable { { return checkinDate; private Long id; } private User user; public void setCheckinDate(Date datetime) private Hotel hotel; { private Date checkinDate; this.checkinDate = datetime; private Date checkoutDate; } private String creditCard; private String creditCardName; @ManyToOne @NotNull private int creditCardExpiryMonth; public Hotel getHotel() private int creditCardExpiryYear; { private boolean smoking; return hotel; private int beds; } public void setHotel(Hotel hotel) public Booking() {} { this.hotel = hotel; public Booking(Hotel hotel, User user) } { this.hotel = hotel; @ManyToOne @NotNull this.user = user; public User getUser() } { return user; } Tuesday, December 15, 2009
  • 83. public int getBeds() public void setUser(User user) { { return beds; this.user = user; } } public void setBeds(int beds) @Basic @Temporal(TemporalType.DATE) { @NotNull this.beds = beds; public Date getCheckoutDate() } { @NotNull(message="Credit card name is required") return checkoutDate; @Length(min=3, max=70, message="Credit card name is required") } public String getCreditCardName() public void setCheckoutDate(Date checkoutDate) { { return creditCardName; this.checkoutDate = checkoutDate; } } public void setCreditCardName(String creditCardName) @NotNull(message="Credit card number is required") { @Length(min=16, max=16, message="Credit card number must 16 digits long") this.creditCardName = creditCardName; @Pattern(regex="^d*$", message="Credit card number must be numeric") } public String getCreditCard() { public int getCreditCardExpiryMonth() return creditCard; { } return creditCardExpiryMonth; } public void setCreditCard(String creditCard) { public void setCreditCardExpiryMonth(int creditCardExpiryMonth) this.creditCard = creditCard; { } this.creditCardExpiryMonth = creditCardExpiryMonth; } @Transient public String getDescription() public int getCreditCardExpiryYear() { { DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM); return creditCardExpiryYear; return hotel==null ? null : hotel.getName() + } ", " + df.format( getCheckinDate() ) + " to " + df.format( getCheckoutDate() ); public void setCreditCardExpiryYear(int creditCardExpiryYear) } { this.creditCardExpiryYear = creditCardExpiryYear; public boolean isSmoking() } { return smoking; @Override } public String toString() { public void setSmoking(boolean smoking) return "Booking(" + user + ","+ hotel + ")"; { } this.smoking = smoking; } } Tuesday, December 15, 2009
  • 84. class Booking < ActiveRecord::Base belongs_to :hotel belongs_to :user validates_presence_of :hotel validates_presence_of :user validates_presence_of :credit_card validates_presence_of :credit_card_name validates_length_of :credit_card, :within => 16..16 validates_format_of :credit_card, :with => /^d*$/ validates_length_of :credit_card_name, :within => 3..70 def total hotel.price * nights end def nights ((checkout_date - checkin_date) / 1.day).round end def to_s "Booking(#{user},#{hotel})" end end Tuesday, December 15, 2009
  • 85. class Booking < ActiveRecord::Base belongs_to :hotel belongs_to :user validates_presence_of :hotel validates_presence_of :user validates_presence_of :credit_card validates_presence_of :credit_card_name validates_length_of :credit_card, :within => 16..16 validates_format_of :credit_card, :with => /^d*$/ validates_length_of :credit_card_name, :within => 3..70 def total hotel.price * nights end def nights ((checkout_date - checkin_date) / 1.day).round end def to_s "Booking(#{user},#{hotel})" end end Tuesday, December 15, 2009
  • 86. class CreateBookings < ActiveRecord::Migration def self.up create_table :bookings do |t| t.references :user t.references :hotel t.datetime :checkin t.datetime :checkout t.string :credit_card t.string :credit_card_name t.integer :credit_card_expiry_month t.integer :credit_card_expiry_year t.boolean :smoking t.integer :beds t.timestamps end end def self.down drop_table :bookings end end Tuesday, December 15, 2009
  • 87. class CreateBookings < ActiveRecord::Migration def self.up create_table :bookings do |t| t.references :user t.references :hotel t.datetime :checkin t.datetime :checkout t.string :credit_card t.string :credit_card_name t.integer :credit_card_expiry_month t.integer :credit_card_expiry_year t.boolean :smoking t.integer :beds t.timestamps end end def self.down drop_table :bookings end end Tuesday, December 15, 2009
  • 88. class CreateBookings < ActiveRecord::Migration def self.up create_table :bookings do |t| t.references :user t.references :hotel t.datetime :checkin t.datetime :checkout t.string :credit_card t.string :credit_card_name t.integer :credit_card_expiry_month t.integer :credit_card_expiry_year t.boolean :smoking t.integer :beds t.timestamps end end def self.down drop_table :bookings end end Tuesday, December 15, 2009
  • 89. 190 vs 40 Tuesday, December 15, 2009
  • 90. “Eles servem mais de 23 milhões de visitantes/mês. A conversão resultou em 20 mil linhas de Ruby em vez de 125 mil linhas de Java e, mais importante, facilitou a dificuldade que tinham em manutenção. Eles também finalizaram a reescrita do sistema em apenas 3 meses com 4 desenvolvedores. Uma vez completo e otimizado, o site deles agora é mais rápido que antes.” http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails Tuesday, December 15, 2009
  • 91. “Eles servem mais de 23 milhões de visitantes/mês. A conversão resultou em 20 mil linhas de Ruby em vez de 125 mil linhas de Java e, mais importante, facilitou a dificuldade que tinham em manutenção. Eles também finalizaram a reescrita do sistema em apenas 3 meses com 4 desenvolvedores. Uma vez completo e otimizado, o site deles agora é mais rápido que antes.” http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails Tuesday, December 15, 2009
  • 92. “Eles servem mais de 23 milhões de visitantes/mês. A conversão resultou em 20 mil linhas de Ruby em vez de 125 mil linhas de Java e, mais importante, facilitou a dificuldade que tinham em manutenção. Eles também finalizaram a reescrita do sistema em apenas 3 meses com 4 desenvolvedores. Uma vez completo e otimizado, o site deles agora é mais rápido que antes.” http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails Tuesday, December 15, 2009
  • 93. “Eles servem mais de 23 milhões de visitantes/mês. A conversão resultou em 20 mil linhas de Ruby em vez de 125 mil linhas de Java e, mais importante, facilitou a dificuldade que tinham em manutenção. Eles também finalizaram a reescrita do sistema em apenas 3 meses com 4 desenvolvedores. Uma vez completo e otimizado, o site deles agora é mais rápido que antes.” http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails Tuesday, December 15, 2009
  • 94. Ferramentas Ágeis Tuesday, December 15, 2009
  • 95. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Capistrano Deployment Puppet Monitoramento New Relic Tuesday, December 15, 2009
  • 96. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Capistrano Deployment Puppet Monitoramento New Relic Tuesday, December 15, 2009
  • 97. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Capistrano Deployment Puppet Monitoramento New Relic Tuesday, December 15, 2009
  • 98. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Capistrano Deployment Puppet Monitoramento New Relic Tuesday, December 15, 2009
  • 122. O que dizem por aí ... Tuesday, December 15, 2009
  • 130. Rails não Escala Tuesday, December 15, 2009
  • 133. Blaine Cook http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter Tuesday, December 15, 2009
  • 134. Para colocar as coisas em perspectiva, o Friendster foi escrito em Java e eles mudaram para PHP. MySpace foi escrito em ColdFusion e eles mudaram para ASP.NET. Blaine Cook http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter Tuesday, December 15, 2009
  • 135. Para colocar as coisas em perspectiva, o Friendster foi escrito em Java e eles mudaram para PHP. MySpace foi escrito em ColdFusion e eles mudaram para ASP.NET. Quando as pessoas caem em problemas de escalabilidade, normalmente acham que a linguagem é o problema, mas eu acho que isso raramente é a realidade. Blaine Cook http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter Tuesday, December 15, 2009
  • 136. “O The New York Times usou Ruby on Rails para agregar, analizar e mostrar os resultados das eleições em quase tempo real em um de seus sites mais acessados de todos os tempos.” http://www.computerworld.com.au/article/268003/ruby_rails_rolls_into_enterprise?fp=16&fpid=1 Tuesday, December 15, 2009
  • 137. “O The New York Times usou Ruby on Rails para agregar, analizar e mostrar os resultados das eleições em quase tempo real em um de seus sites mais acessados de todos os tempos.” http://www.computerworld.com.au/article/268003/ruby_rails_rolls_into_enterprise?fp=16&fpid=1 Tuesday, December 15, 2009
  • 138. Ruby é Lento Tuesday, December 15, 2009
  • 139. x mais lento que C++ Tuesday, December 15, 2009
  • 140. x mais lento que C++ 0 50 100 150 200 Python 2 Ruby 1.9 Perl JRuby Python 3 PHP Ruby 1.8.6 Tuesday, December 15, 2009
  • 141. Homepage: 331 ms Tuesday, December 15, 2009
  • 142. Homepage: 331 ms Total: 5.45 s Tuesday, December 15, 2009
  • 144. Performance != Escalabilidade Tuesday, December 15, 2009
  • 147. Mais Produtivo “Melhor” Anti-legado Tuesday, December 15, 2009
  • 148. Sempre se Lembre Poderíamos contratar um Macaco Treinado para fazer seu Trabalho! Tuesday, December 15, 2009
  • 151. Robert C. Martin Tuesday, December 15, 2009
  • 155. Test Driven Development Tuesday, December 15, 2009
  • 157. describe BankAccount do before :each do @bank_account = BankAccount.new :balance => 250 end it "should not be valid" do @bank_account.should be_valid end it "should transfer funds successfully" do @bank_account.should_receive(:transfer) .with_args(:amount => 100) .and_return(true) @bank_account.execute_transaction(:amount => 100) @bank_account.balance.should == 150 end end Tuesday, December 15, 2009
  • 158. describe BankAccount do before :each do @bank_account = BankAccount.new :balance => 250 end it "should not be valid" do @bank_account.should be_valid end it "should transfer funds successfully" do @bank_account.should_receive(:transfer) .with_args(:amount => 100) .and_return(true) @bank_account.execute_transaction(:amount => 100) @bank_account.balance.should == 150 end end Tuesday, December 15, 2009
  • 159. describe BankAccount do before :each do @bank_account = BankAccount.new :balance => 250 end it "should not be valid" do @bank_account.should be_valid end it "should transfer funds successfully" do @bank_account.should_receive(:transfer) .with_args(:amount => 100) .and_return(true) @bank_account.execute_transaction(:amount => 100) @bank_account.balance.should == 150 end end Tuesday, December 15, 2009
  • 160. describe BankAccount do before :each do @bank_account = BankAccount.new :balance => 250 end it "should not be valid" do @bank_account.should be_valid end it "should transfer funds successfully" do @bank_account.should_receive(:transfer) .with_args(:amount => 100) .and_return(true) @bank_account.execute_transaction(:amount => 100) @bank_account.balance.should == 150 end end Tuesday, December 15, 2009
  • 162. Funcionalidade: Adição Para evitar erros bobos Como um péssimo matemático Eu quero saber como somar dois números Cenário: Adicionar dois números Dado que eu digitei 50 na calculadora E que eu digitei 70 na calculadora Quando eu aperto o botão de soma Então o resultado na calculadora deve ser 120 Tuesday, December 15, 2009
  • 163. Funcionalidade: Adição Para evitar erros bobos Como um péssimo matemático Eu quero saber como somar dois números Cenário: Adicionar dois números Dado que eu digitei 50 na calculadora E que eu digitei 70 na calculadora Quando eu aperto o botão de soma Então o resultado na calculadora deve ser 120 Tuesday, December 15, 2009
  • 166. Não é mais demorado? Tuesday, December 15, 2009
  • 167. Produtividade Cowboy Profissional Tuesday, December 15, 2009
  • 168. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Tuesday, December 15, 2009
  • 169. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Tuesday, December 15, 2009
  • 170. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Tuesday, December 15, 2009
  • 171. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Tuesday, December 15, 2009
  • 172. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Tuesday, December 15, 2009
  • 173. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Tuesday, December 15, 2009
  • 174. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Tuesday, December 15, 2009
  • 175. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Tuesday, December 15, 2009
  • 176. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Tuesday, December 15, 2009
  • 179. 237 Equipes 137 Finalizadas Tuesday, December 15, 2009
  • 181. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Tuesday, December 15, 2009
  • 182. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Tuesday, December 15, 2009
  • 183. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Tuesday, December 15, 2009
  • 184. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Tuesday, December 15, 2009
  • 185. Post hoc ergo propter hoc Tuesday, December 15, 2009
  • 188. Obrigado! akitaonrails.com railssummit.com.br Tuesday, December 15, 2009