Ruby on Rails
Tuesday, December 15, 2009
AkitaOnRails.com




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

                             fabio.akita@locaweb.com.br




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

                         Ruby   1.8

        “Novo” Ruby             1.9
Tuesday, December ...
Ruby on Rails             2.3

                         Ruby   1.8

        “Novo” Ruby             1.9
Tuesday, December ...
Ruby on Rails             2.3

                         Ruby   1.8

        “Novo” Ruby             1.9
Tuesday, December ...
“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
Tuesday, December 15, 2009
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”
    ...
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
                                          ob...
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

      ...
Código que gera Código

          Convention over Con guration

                             Don’t Repeat Yourself

      ...
Código que gera Código

          Convention over Con guration

                             Don’t Repeat Yourself

      ...
Código que gera Código

          Convention over Con guration

                             Don’t Repeat Yourself

      ...
Restful Resources

                    Unicode, Time Zone, i18n

        Segurança (XSS, CSRF, Injection)

              R...
Restful Resources

                    Unicode, Time Zone, i18n

        Segurança (XSS, CSRF, Injection)

              R...
Restful Resources

                    Unicode, Time Zone, i18n

        Segurança (XSS, CSRF, Injection)

              R...
Restful Resources

                    Unicode, Time Zone, i18n

        Segurança (XSS, CSRF, Injection)

              R...
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 =...
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent =...
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent =...
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent =...
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent =...
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent =...
Model
  class Product < ActiveRecord::Base
    after_create :set_initial_inventory

      has_many :variants, :dependent =...
Views ERB
  <div id="product-listing">
    <%= breadcrumbs(@taxon) %>
    <br/>
    <%= render :partial => "shared/product...
Views ERB
  <div id="product-listing">
    <%= breadcrumbs(@taxon) %>
    <br/>
    <%= render :partial => "shared/product...
Views ERB
  <div id="product-listing">
    <%= breadcrumbs(@taxon) %>
    <br/>
    <%= render :partial => "shared/product...
Rotas RESTFul


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

      map.resources :products
      map.resources :addr...
Rotas RESTFul


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

      map.resources :products
      map.resources :addr...
Rotas RESTFul


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

      map.resources :products
      map.resources :addr...
Rotas RESTFul


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

      map.resources :products
      map.resources :addr...
Rotas RESTFul

                 GET /products/new
  ActionController::Routing::Routes.draw do |map|
                 GET /...
Controller
    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_ext...
Controller
    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_ext...
Controller
    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_ext...
“Beautiful Code”


Tuesday, December 15, 2009
@Transient
                                                                 public BigDecimal getTotal()
      //$Id: Book...
public int getBeds()
  public void setUser(User user)
                                                                    ...
class Booking < ActiveRecord::Base
               belongs_to :hotel
               belongs_to :user
               validat...
class Booking < ActiveRecord::Base
               belongs_to :hotel
               belongs_to :user
               validat...
class CreateBookings < ActiveRecord::Migration
                        def self.up
                          create_table ...
class CreateBookings < ActiveRecord::Migration
                        def self.up
                          create_table ...
class CreateBookings < ActiveRecord::Migration
                        def self.up
                          create_table ...
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 12...
“Eles servem mais de 23 milhões de visitantes/mês. A conversão
             resultou em 20 mil linhas de Ruby em vez de 12...
“Eles servem mais de 23 milhões de visitantes/mês. A conversão
             resultou em 20 mil linhas de Ruby em vez de 12...
“Eles servem mais de 23 milhões de visitantes/mês. A conversão
             resultou em 20 mil linhas de Ruby em vez de 12...
Ferramentas
                                Ágeis


Tuesday, December 15, 2009
Gitorious
       Repositórios
                                   Github
       Integração                 Integrity
      ...
Gitorious
       Repositórios
                                   Github
       Integração                 Integrity
      ...
Gitorious
       Repositórios
                                   Github
       Integração                 Integrity
      ...
Gitorious
       Repositórios
                                   Github
       Integração                 Integrity
      ...
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
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


Tuesda...
Para colocar as coisas em
       perspectiva, o Friendster foi
         escrito em Java e eles
          mudaram para PHP....
Para colocar as coisas em
       perspectiva, o Friendster foi
         escrito em Java e eles
          mudaram para PHP....
“O The New York Times usou Ruby on Rails
                 para agregar, analizar e mostrar os
              resultados das...
“O The New York Times usou Ruby on Rails
                 para agregar, analizar e mostrar os
              resultados das...
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


     ...
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!
Tu...
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
          en...
describe BankAccount do
          before :each do
            @bank_account = BankAccount.new :balance => 250
          en...
describe BankAccount do
          before :each do
            @bank_account = BankAccount.new :balance => 250
          en...
describe BankAccount do
          before :each do
            @bank_account = BankAccount.new :balance => 250
          en...
Tuesday, December 15, 2009
Funcionalidade: Adição
               Para evitar erros bobos
               Como um péssimo matemático
               Eu ...
Funcionalidade: Adição
               Para evitar erros bobos
               Como um péssimo matemático
               Eu ...
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



           ...
Produtividade
                                  Cowboy                   Profissional

                70.00



           ...
Produtividade
                                  Cowboy                   Profissional

                70.00



           ...
Produtividade
                                  Cowboy                   Profissional

                70.00



           ...
Produtividade
                                  Cowboy                   Profissional

                70.00



           ...
Produtividade
                                  Cowboy                   Profissional

                70.00



           ...
Produtividade
                                  Cowboy                   Profissional

                70.00



           ...
Produtividade
                                  Cowboy                   Profissional

                70.00



           ...
Produtividade
                                  Cowboy                   Profissional

                70.00



           ...
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

         ...
Empreendedorismo

                             Código e “Forma”

                     Ciclo de Vida de Projetos

         ...
Empreendedorismo

                             Código e “Forma”

                     Ciclo de Vida de Projetos

         ...
Empreendedorismo

                             Código e “Forma”

                     Ciclo de Vida de Projetos

         ...
Pro ssionalismo


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



Tuesday, Decem...
Tuesday, December 15, 2009
Upcoming SlideShare
Loading in …5
×

Latinoware Rails 2009

649 views
598 views

Published on

Ruby on Rails e Agilidade em Foz do Iguaçu. Dia 23/out.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

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

No notes for slide

Latinoware Rails 2009

  1. 1. Ruby on Rails Tuesday, December 15, 2009
  2. 2. AkitaOnRails.com Tuesday, December 15, 2009
  3. 3. www.slideshare.net/akitaonrails fabio.akita@locaweb.com.br Tuesday, December 15, 2009
  4. 4. Tuesday, December 15, 2009
  5. 5. Ruby on Rails 2.3 Ruby 1.8 “Novo” Ruby 1.9 Tuesday, December 15, 2009
  6. 6. Ruby on Rails 2.3 Ruby 1.8 “Novo” Ruby 1.9 Tuesday, December 15, 2009
  7. 7. Ruby on Rails 2.3 Ruby 1.8 “Novo” Ruby 1.9 Tuesday, December 15, 2009
  8. 8. “Matz” 1993 Tuesday, December 15, 2009
  9. 9. Tuesday, December 15, 2009
  10. 10. “Prag Dave” 2001 Tuesday, December 15, 2009
  11. 11. Tuesday, December 15, 2009
  12. 12. “DHH” 2004 Tuesday, December 15, 2009
  13. 13. Tuesday, December 15, 2009
  14. 14. Tuesday, December 15, 2009
  15. 15. Tuesday, December 15, 2009
  16. 16. Tuesday, December 15, 2009
  17. 17. Charles Nutter 2006 Tuesday, December 15, 2009
  18. 18. Tuesday, December 15, 2009
  19. 19. Tuesday, December 15, 2009
  20. 20. Tuesday, December 15, 2009
  21. 21. Tuesday, December 15, 2009
  22. 22. “Tornar as coisas simples fáceis e as coisas complexas possíveis” Filoso a Ruby Tuesday, December 15, 2009
  23. 23. Tuesday, December 15, 2009
  24. 24. Tuesday, December 15, 2009
  25. 25. Tuesday, December 15, 2009
  26. 26. Tuesday, December 15, 2009
  27. 27. Orientação a Objetos? Tuesday, December 15, 2009
  28. 28. Tuesday, December 15, 2009
  29. 29. Alan Kay Dan Ingalls Tuesday, December 15, 2009
  30. 30. Alan Kay Tuesday, December 15, 2009
  31. 31. Alan Kay Tuesday, December 15, 2009
  32. 32. 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
  33. 33. Meta- programação Tuesday, December 15, 2009
  34. 34. Meta- apresentação Tuesday, December 15, 2009
  35. 35. Tuesday, December 15, 2009
  36. 36. Ruby on Rails Tuesday, December 15, 2009
  37. 37. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Tuesday, December 15, 2009
  38. 38. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Tuesday, December 15, 2009
  39. 39. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Tuesday, December 15, 2009
  40. 40. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Tuesday, December 15, 2009
  41. 41. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Rack Support (Middlewares) Tuesday, December 15, 2009
  42. 42. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Rack Support (Middlewares) Tuesday, December 15, 2009
  43. 43. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Rack Support (Middlewares) Tuesday, December 15, 2009
  44. 44. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Rack Support (Middlewares) Tuesday, December 15, 2009
  45. 45. Tuesday, December 15, 2009
  46. 46. Tuesday, December 15, 2009
  47. 47. Tuesday, December 15, 2009
  48. 48. Tuesday, December 15, 2009
  49. 49. Tuesday, December 15, 2009
  50. 50. Tuesday, December 15, 2009
  51. 51. Tuesday, December 15, 2009
  52. 52. Tuesday, December 15, 2009
  53. 53. Tuesday, December 15, 2009
  54. 54. Tuesday, December 15, 2009
  55. 55. Tuesday, December 15, 2009
  56. 56. Tuesday, December 15, 2009
  57. 57. 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
  58. 58. 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
  59. 59. 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
  60. 60. 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
  61. 61. 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
  62. 62. 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
  63. 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. 64. 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
  65. 65. 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
  66. 66. 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
  67. 67. 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
  68. 68. 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
  69. 69. 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
  70. 70. 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
  71. 71. 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
  72. 72. 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
  73. 73. 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
  74. 74. 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
  75. 75. “Beautiful Code” Tuesday, December 15, 2009
  76. 76. @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
  77. 77. 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
  78. 78. 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
  79. 79. 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
  80. 80. 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
  81. 81. 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
  82. 82. 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
  83. 83. 190 vs 40 Tuesday, December 15, 2009
  84. 84. “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
  85. 85. “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
  86. 86. “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
  87. 87. “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
  88. 88. Ferramentas Ágeis Tuesday, December 15, 2009
  89. 89. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Capistrano Deployment Puppet Monitoramento New Relic Tuesday, December 15, 2009
  90. 90. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Capistrano Deployment Puppet Monitoramento New Relic Tuesday, December 15, 2009
  91. 91. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Capistrano Deployment Puppet Monitoramento New Relic Tuesday, December 15, 2009
  92. 92. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Capistrano Deployment Puppet Monitoramento New Relic Tuesday, December 15, 2009
  93. 93. Tuesday, December 15, 2009
  94. 94. Tuesday, December 15, 2009
  95. 95. Comunidade Tuesday, December 15, 2009
  96. 96. Tuesday, December 15, 2009
  97. 97. Tuesday, December 15, 2009
  98. 98. Tuesday, December 15, 2009
  99. 99. Tuesday, December 15, 2009
  100. 100. Tuesday, December 15, 2009
  101. 101. Tuesday, December 15, 2009
  102. 102. Tuesday, December 15, 2009
  103. 103. Tuesday, December 15, 2009
  104. 104. Tuesday, December 15, 2009
  105. 105. Tuesday, December 15, 2009
  106. 106. Tuesday, December 15, 2009
  107. 107. Tuesday, December 15, 2009
  108. 108. Tuesday, December 15, 2009
  109. 109. Tuesday, December 15, 2009
  110. 110. Tuesday, December 15, 2009
  111. 111. Tuesday, December 15, 2009
  112. 112. Tuesday, December 15, 2009
  113. 113. Tuesday, December 15, 2009
  114. 114. Tuesday, December 15, 2009
  115. 115. O que dizem por aí ... Tuesday, December 15, 2009
  116. 116. Pouco usado Tuesday, December 15, 2009
  117. 117. Tuesday, December 15, 2009
  118. 118. Tuesday, December 15, 2009
  119. 119. Tuesday, December 15, 2009
  120. 120. Tuesday, December 15, 2009
  121. 121. Tuesday, December 15, 2009
  122. 122. Tuesday, December 15, 2009
  123. 123. Rails não Escala Tuesday, December 15, 2009
  124. 124. Tuesday, December 15, 2009
  125. 125. Tuesday, December 15, 2009
  126. 126. Blaine Cook http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter Tuesday, December 15, 2009
  127. 127. 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
  128. 128. 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
  129. 129. “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
  130. 130. “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
  131. 131. Ruby é Lento Tuesday, December 15, 2009
  132. 132. x mais lento que C++ Tuesday, December 15, 2009
  133. 133. 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
  134. 134. Homepage: 331 ms Tuesday, December 15, 2009
  135. 135. Homepage: 331 ms Total: 5.45 s Tuesday, December 15, 2009
  136. 136. Tuesday, December 15, 2009
  137. 137. Performance != Escalabilidade Tuesday, December 15, 2009
  138. 138. Outros Mitos? Tuesday, December 15, 2009
  139. 139. Tuesday, December 15, 2009
  140. 140. Mais Produtivo “Melhor” Anti-legado Tuesday, December 15, 2009
  141. 141. Sempre se Lembre Poderíamos contratar um Macaco Treinado para fazer seu Trabalho! Tuesday, December 15, 2009
  142. 142. Agilidade Tuesday, December 15, 2009
  143. 143. Tuesday, December 15, 2009
  144. 144. Robert C. Martin Tuesday, December 15, 2009
  145. 145. Tuesday, December 15, 2009
  146. 146. Código Limpo Tuesday, December 15, 2009
  147. 147. Tuesday, December 15, 2009
  148. 148. Test Driven Development Tuesday, December 15, 2009
  149. 149. Tuesday, December 15, 2009
  150. 150. 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
  151. 151. 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
  152. 152. 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
  153. 153. 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
  154. 154. Tuesday, December 15, 2009
  155. 155. 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
  156. 156. 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
  157. 157. Tuesday, December 15, 2009
  158. 158. Tuesday, December 15, 2009
  159. 159. Não é mais demorado? Tuesday, December 15, 2009
  160. 160. Produtividade Cowboy Profissional Tuesday, December 15, 2009
  161. 161. 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
  162. 162. 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
  163. 163. 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
  164. 164. 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
  165. 165. 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
  166. 166. 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
  167. 167. 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
  168. 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. 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. 170. Tuesday, December 15, 2009
  171. 171. Tuesday, December 15, 2009
  172. 172. 237 Equipes 137 Finalizadas Tuesday, December 15, 2009
  173. 173. Tuesday, December 15, 2009
  174. 174. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Tuesday, December 15, 2009
  175. 175. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Tuesday, December 15, 2009
  176. 176. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Tuesday, December 15, 2009
  177. 177. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Tuesday, December 15, 2009
  178. 178. Pro ssionalismo Tuesday, December 15, 2009
  179. 179. Tuesday, December 15, 2009
  180. 180. Obrigado! akitaonrails.com railssummit.com.br Tuesday, December 15, 2009
  181. 181. Tuesday, December 15, 2009

×