A apresentação comecará em alguns minutos ...




Saturday, March 20, 2010
Saturday, March 20, 2010
Ruby on Rails
Saturday, March 20, 2010
AkitaOnRails.com




Saturday, March 20, 2010
~ 50 min
                           ~ 110 slides



Saturday, March 20, 2010
www.slideshare.net/akitaonrails


                           fabioakita@gmail.com




Saturday, March 20, 2010
Saturday, March 20, 2010
Ruby on Rails               2.3.x
       Ruby on Rails              3.0-pre
                           Ruby    1.8.x
     ...
Ruby on Rails               2.3.x
       Ruby on Rails              3.0-pre
                           Ruby    1.8.x
     ...
Ruby on Rails               2.3.x
       Ruby on Rails              3.0-pre
                           Ruby    1.8.x
     ...
Ruby on Rails               2.3.x
       Ruby on Rails              3.0-pre
                           Ruby    1.8.x
     ...
“Matz”




                           1993
Saturday, March 20, 2010
Saturday, March 20, 2010
“DHH”


                           2004
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Charles Nutter



                            2006
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
http://github.com/akitaonrails/jruby_calculator_demo/

Saturday, March 20, 2010
http://github.com/akitaonrails/jruby_calculator_demo/

Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
“Tornar as coisas
                 simples fáceis e as
                 coisas complexas
                     possíveis”
 ...
Ruby on Rails


Saturday, March 20, 2010
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
              ...
Restful Resources

                     Unicode, Time Zone, i18n

                                Segurança
              ...
Restful Resources

                     Unicode, Time Zone, i18n

                                Segurança
              ...
Templates           ERB, HAML


                              HTTP Basic, HTTP Digest,
            Autenticação         Au...
Templates           ERB, HAML


                              HTTP Basic, HTTP Digest,
            Autenticação         Au...
Templates           ERB, HAML


                              HTTP Basic, HTTP Digest,
            Autenticação         Au...
Templates           ERB, HAML


                              HTTP Basic, HTTP Digest,
            Autenticação         Au...
Templates           ERB, HAML


                              HTTP Basic, HTTP Digest,
            Autenticação         Au...
Templates           ERB, HAML


                              HTTP Basic, HTTP Digest,
            Autenticação         Au...
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
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...
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”


Saturday, March 20, 2010
@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
                               cre...
class CreateBookings < ActiveRecord::Migration
                             def self.up
                               cre...
class CreateBookings < ActiveRecord::Migration
                             def self.up
                               cre...
190
                           vs
                           40


Saturday, March 20, 2010
Saturday, March 20, 2010
“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


Saturday, March 20, 2010
Gitorious
        Repositórios
                                 Github
        Integração              Integrity
        C...
Gitorious
        Repositórios
                                 Github
        Integração              Integrity
        C...
Gitorious
        Repositórios
                                 Github
        Integração              Integrity
        C...
Gitorious
        Repositórios
                                 Github
        Integração              Integrity
        C...
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Comunidade


Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
O que dizem
                             por aí ...


Saturday, March 20, 2010
Ruby é Lento


Saturday, March 20, 2010
Existem mentiras,
             mentiras malditas e
                estatísticas.

Saturday, March 20, 2010
Existem mentiras,
             mentiras malditas e
                estatísticas.

Saturday, March 20, 2010
Existem mentiras,
             mentiras malditas e
                estatísticas.

Saturday, March 20, 2010
Saturday, March 20, 2010
x mais lento que C++




Saturday, March 20, 2010
x mais lento que C++


                           0   32.5             65           97.5   130

  Python 2


   Ruby 1.9

...
Homepage: 331 ms




Saturday, March 20, 2010
Homepage: 331 ms

                           Total: 5.45 s

Saturday, March 20, 2010
Saturday, March 20, 2010
Performance
                             !=
                       Escalabilidade

Saturday, March 20, 2010
Rails não Escala


Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Blaine Cook

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


Saturday...
Para colocar as coisas em
        perspectiva, o Friendster foi
          escrito em Java e eles
           mudaram para P...
Para colocar as coisas em
        perspectiva, o Friendster foi
          escrito em Java e eles
           mudaram para P...
“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...
Browser




                       Web Server




                           MySQL




Saturday, March 20, 2010
Browser


                                     Varnish/HAProxy


                       Web Server




                   ...
Browser


                                     Varnish/HAProxy


                       Web Server


                     ...
Browser


                                      Varnish/HAProxy


                       Web Server


                    ...
Saturday, March 20, 2010
Outros Mitos?


Saturday, March 20, 2010
Saturday, March 20, 2010
Mais Produtivo

                            “Melhor”

                           Anti-legado
Saturday, March 20, 2010
Sempre se Lembre




             Poderíamos contratar um Macaco Treinado
                     para fazer seu Trabalho!
Sa...
Saturday, March 20, 2010
Saturday, March 20, 2010
Saturday, March 20, 2010
Agilidade


Saturday, March 20, 2010
Saturday, March 20, 2010
Robert C. Martin


Saturday, March 20, 2010
Saturday, March 20, 2010
Código Limpo


Saturday, March 20, 2010
Saturday, March 20, 2010
Test Driven
                           Development


Saturday, March 20, 2010
Saturday, March 20, 2010
describe BankAccount do
           before :each do
             @bank_account = BankAccount.new :balance => 250
          ...
describe BankAccount do
           before :each do
             @bank_account = BankAccount.new :balance => 250
          ...
describe BankAccount do
           before :each do
             @bank_account = BankAccount.new :balance => 250
          ...
describe BankAccount do
           before :each do
             @bank_account = BankAccount.new :balance => 250
          ...
Saturday, March 20, 2010
Funcionalidade: Adição
                Para evitar erros bobos
                Como um péssimo matemático
                ...
Funcionalidade: Adição
                Para evitar erros bobos
                Como um péssimo matemático
                ...
Saturday, March 20, 2010
Saturday, March 20, 2010
Não é mais
                           demorado?


Saturday, March 20, 2010
Produtividade
                           Cowboy    Profissional




Saturday, March 20, 2010
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



             ...
Saturday, March 20, 2010
Saturday, March 20, 2010
237 Equipes
                    137 Finalizadas


Saturday, March 20, 2010
Saturday, March 20, 2010
Upcoming SlideShare
Loading in …5
×

Edted 2010 Ruby on Rails

962 views

Published on

Palestra de introdução à Cultura e Ecossistema Ruby on Rails no EDTED 2010 Rio de Janeiro

Published in: Technology
  • Be the first to comment

Edted 2010 Ruby on Rails

  1. 1. A apresentação comecará em alguns minutos ... Saturday, March 20, 2010
  2. 2. Saturday, March 20, 2010
  3. 3. Ruby on Rails Saturday, March 20, 2010
  4. 4. AkitaOnRails.com Saturday, March 20, 2010
  5. 5. ~ 50 min ~ 110 slides Saturday, March 20, 2010
  6. 6. www.slideshare.net/akitaonrails fabioakita@gmail.com Saturday, March 20, 2010
  7. 7. Saturday, March 20, 2010
  8. 8. Ruby on Rails 2.3.x Ruby on Rails 3.0-pre Ruby 1.8.x Ruby 1.9.x Saturday, March 20, 2010
  9. 9. Ruby on Rails 2.3.x Ruby on Rails 3.0-pre Ruby 1.8.x Ruby 1.9.x Saturday, March 20, 2010
  10. 10. Ruby on Rails 2.3.x Ruby on Rails 3.0-pre Ruby 1.8.x Ruby 1.9.x Saturday, March 20, 2010
  11. 11. Ruby on Rails 2.3.x Ruby on Rails 3.0-pre Ruby 1.8.x Ruby 1.9.x Saturday, March 20, 2010
  12. 12. “Matz” 1993 Saturday, March 20, 2010
  13. 13. Saturday, March 20, 2010
  14. 14. “DHH” 2004 Saturday, March 20, 2010
  15. 15. Saturday, March 20, 2010
  16. 16. Saturday, March 20, 2010
  17. 17. Saturday, March 20, 2010
  18. 18. Saturday, March 20, 2010
  19. 19. Saturday, March 20, 2010
  20. 20. Charles Nutter 2006 Saturday, March 20, 2010
  21. 21. Saturday, March 20, 2010
  22. 22. Saturday, March 20, 2010
  23. 23. http://github.com/akitaonrails/jruby_calculator_demo/ Saturday, March 20, 2010
  24. 24. http://github.com/akitaonrails/jruby_calculator_demo/ Saturday, March 20, 2010
  25. 25. Saturday, March 20, 2010
  26. 26. Saturday, March 20, 2010
  27. 27. “Tornar as coisas simples fáceis e as coisas complexas possíveis” Filoso a Ruby Saturday, March 20, 2010
  28. 28. Ruby on Rails Saturday, March 20, 2010
  29. 29. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Saturday, March 20, 2010
  30. 30. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Saturday, March 20, 2010
  31. 31. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Saturday, March 20, 2010
  32. 32. Código que gera Código Convention over Con guration Don’t Repeat Yourself Extreme Programming Saturday, March 20, 2010
  33. 33. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Saturday, March 20, 2010
  34. 34. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Saturday, March 20, 2010
  35. 35. Restful Resources Unicode, Time Zone, i18n Segurança (XSS, CSRF, Injection) Saturday, March 20, 2010
  36. 36. Templates ERB, HAML HTTP Basic, HTTP Digest, Autenticação Authlogic, Devise MySQL, PostgreSQL, Oracle, Bancos de Dados MongoDB, CouchDB ActiveRecord, DataMapper, ORMs MongoMapper, Sequel Prototype, jQuery, Javascript SproutCore Apache 2, NginX, Web Servers Lighty, Litespeed Saturday, March 20, 2010
  37. 37. Templates ERB, HAML HTTP Basic, HTTP Digest, Autenticação Authlogic, Devise MySQL, PostgreSQL, Oracle, Bancos de Dados MongoDB, CouchDB ActiveRecord, DataMapper, ORMs MongoMapper, Sequel Prototype, jQuery, Javascript SproutCore Apache 2, NginX, Web Servers Lighty, Litespeed Saturday, March 20, 2010
  38. 38. Templates ERB, HAML HTTP Basic, HTTP Digest, Autenticação Authlogic, Devise MySQL, PostgreSQL, Oracle, Bancos de Dados MongoDB, CouchDB ActiveRecord, DataMapper, ORMs MongoMapper, Sequel Prototype, jQuery, Javascript SproutCore Apache 2, NginX, Web Servers Lighty, Litespeed Saturday, March 20, 2010
  39. 39. Templates ERB, HAML HTTP Basic, HTTP Digest, Autenticação Authlogic, Devise MySQL, PostgreSQL, Oracle, Bancos de Dados MongoDB, CouchDB ActiveRecord, DataMapper, ORMs MongoMapper, Sequel Prototype, jQuery, Javascript SproutCore Apache 2, NginX, Web Servers Lighty, Litespeed Saturday, March 20, 2010
  40. 40. Templates ERB, HAML HTTP Basic, HTTP Digest, Autenticação Authlogic, Devise MySQL, PostgreSQL, Oracle, Bancos de Dados MongoDB, CouchDB ActiveRecord, DataMapper, ORMs MongoMapper, Sequel Prototype, jQuery, Javascript SproutCore Apache 2, NginX, Web Servers Lighty, Litespeed Saturday, March 20, 2010
  41. 41. Templates ERB, HAML HTTP Basic, HTTP Digest, Autenticação Authlogic, Devise MySQL, PostgreSQL, Oracle, Bancos de Dados MongoDB, CouchDB ActiveRecord, DataMapper, ORMs MongoMapper, Sequel Prototype, jQuery, Javascript SproutCore Apache 2, NginX, Web Servers Lighty, Litespeed Saturday, March 20, 2010
  42. 42. Saturday, March 20, 2010
  43. 43. Saturday, March 20, 2010
  44. 44. Saturday, March 20, 2010
  45. 45. Saturday, March 20, 2010
  46. 46. Saturday, March 20, 2010
  47. 47. Saturday, March 20, 2010
  48. 48. Saturday, March 20, 2010
  49. 49. Saturday, March 20, 2010
  50. 50. Saturday, March 20, 2010
  51. 51. Saturday, March 20, 2010
  52. 52. Saturday, March 20, 2010
  53. 53. Saturday, March 20, 2010
  54. 54. Saturday, March 20, 2010
  55. 55. Saturday, March 20, 2010
  56. 56. Saturday, March 20, 2010
  57. 57. Saturday, March 20, 2010
  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 Saturday, March 20, 2010
  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 Saturday, March 20, 2010
  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 Saturday, March 20, 2010
  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 Saturday, March 20, 2010
  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 Saturday, March 20, 2010
  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 Saturday, March 20, 2010
  64. 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 Saturday, March 20, 2010
  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? %> Saturday, March 20, 2010
  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? %> Saturday, March 20, 2010
  67. 67. 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? %> Saturday, March 20, 2010
  68. 68. 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 Saturday, March 20, 2010
  69. 69. 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 Saturday, March 20, 2010
  70. 70. 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 Saturday, March 20, 2010
  71. 71. “Beautiful Code” Saturday, March 20, 2010
  72. 72. @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; } Saturday, March 20, 2010
  73. 73. 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; } } Saturday, March 20, 2010
  74. 74. 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 Saturday, March 20, 2010
  75. 75. 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 Saturday, March 20, 2010
  76. 76. 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 Saturday, March 20, 2010
  77. 77. 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 Saturday, March 20, 2010
  78. 78. 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 Saturday, March 20, 2010
  79. 79. 190 vs 40 Saturday, March 20, 2010
  80. 80. Saturday, March 20, 2010
  81. 81. “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 Saturday, March 20, 2010
  82. 82. “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 Saturday, March 20, 2010
  83. 83. “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 Saturday, March 20, 2010
  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 Saturday, March 20, 2010
  85. 85. Ferramentas Saturday, March 20, 2010
  86. 86. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Chef Deployment Puppet Monitoramento New Relic Saturday, March 20, 2010
  87. 87. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Chef Deployment Puppet Monitoramento New Relic Saturday, March 20, 2010
  88. 88. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Chef Deployment Puppet Monitoramento New Relic Saturday, March 20, 2010
  89. 89. Gitorious Repositórios Github Integração Integrity Contínua Cruise Control Chef Deployment Puppet Monitoramento New Relic Saturday, March 20, 2010
  90. 90. Saturday, March 20, 2010
  91. 91. Saturday, March 20, 2010
  92. 92. Saturday, March 20, 2010
  93. 93. Saturday, March 20, 2010
  94. 94. Saturday, March 20, 2010
  95. 95. Saturday, March 20, 2010
  96. 96. Saturday, March 20, 2010
  97. 97. Comunidade Saturday, March 20, 2010
  98. 98. Saturday, March 20, 2010
  99. 99. Saturday, March 20, 2010
  100. 100. Saturday, March 20, 2010
  101. 101. Saturday, March 20, 2010
  102. 102. Saturday, March 20, 2010
  103. 103. Saturday, March 20, 2010
  104. 104. Saturday, March 20, 2010
  105. 105. Saturday, March 20, 2010
  106. 106. Saturday, March 20, 2010
  107. 107. Saturday, March 20, 2010
  108. 108. Saturday, March 20, 2010
  109. 109. Saturday, March 20, 2010
  110. 110. Saturday, March 20, 2010
  111. 111. Saturday, March 20, 2010
  112. 112. Saturday, March 20, 2010
  113. 113. Saturday, March 20, 2010
  114. 114. Saturday, March 20, 2010
  115. 115. Saturday, March 20, 2010
  116. 116. O que dizem por aí ... Saturday, March 20, 2010
  117. 117. Ruby é Lento Saturday, March 20, 2010
  118. 118. Existem mentiras, mentiras malditas e estatísticas. Saturday, March 20, 2010
  119. 119. Existem mentiras, mentiras malditas e estatísticas. Saturday, March 20, 2010
  120. 120. Existem mentiras, mentiras malditas e estatísticas. Saturday, March 20, 2010
  121. 121. Saturday, March 20, 2010
  122. 122. x mais lento que C++ Saturday, March 20, 2010
  123. 123. x mais lento que C++ 0 32.5 65 97.5 130 Python 2 Ruby 1.9 JRuby Perl Python 3 PHP Ruby 1.8 Saturday, March 20, 2010
  124. 124. Homepage: 331 ms Saturday, March 20, 2010
  125. 125. Homepage: 331 ms Total: 5.45 s Saturday, March 20, 2010
  126. 126. Saturday, March 20, 2010
  127. 127. Performance != Escalabilidade Saturday, March 20, 2010
  128. 128. Rails não Escala Saturday, March 20, 2010
  129. 129. Saturday, March 20, 2010
  130. 130. Saturday, March 20, 2010
  131. 131. Blaine Cook http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter Saturday, March 20, 2010
  132. 132. 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 Saturday, March 20, 2010
  133. 133. 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 Saturday, March 20, 2010
  134. 134. “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 Saturday, March 20, 2010
  135. 135. “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 Saturday, March 20, 2010
  136. 136. Browser Web Server MySQL Saturday, March 20, 2010
  137. 137. Browser Varnish/HAProxy Web Server MySQL Saturday, March 20, 2010
  138. 138. Browser Varnish/HAProxy Web Server Memcached MySQL Saturday, March 20, 2010
  139. 139. Browser Varnish/HAProxy Web Server Memcached MySQL CouchDB/MongoDB Saturday, March 20, 2010
  140. 140. Saturday, March 20, 2010
  141. 141. Outros Mitos? Saturday, March 20, 2010
  142. 142. Saturday, March 20, 2010
  143. 143. Mais Produtivo “Melhor” Anti-legado Saturday, March 20, 2010
  144. 144. Sempre se Lembre Poderíamos contratar um Macaco Treinado para fazer seu Trabalho! Saturday, March 20, 2010
  145. 145. Saturday, March 20, 2010
  146. 146. Saturday, March 20, 2010
  147. 147. Saturday, March 20, 2010
  148. 148. Agilidade Saturday, March 20, 2010
  149. 149. Saturday, March 20, 2010
  150. 150. Robert C. Martin Saturday, March 20, 2010
  151. 151. Saturday, March 20, 2010
  152. 152. Código Limpo Saturday, March 20, 2010
  153. 153. Saturday, March 20, 2010
  154. 154. Test Driven Development Saturday, March 20, 2010
  155. 155. Saturday, March 20, 2010
  156. 156. 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 Saturday, March 20, 2010
  157. 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 Saturday, March 20, 2010
  158. 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 Saturday, March 20, 2010
  159. 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 Saturday, March 20, 2010
  160. 160. Saturday, March 20, 2010
  161. 161. 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 Saturday, March 20, 2010
  162. 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 Saturday, March 20, 2010
  163. 163. Saturday, March 20, 2010
  164. 164. Saturday, March 20, 2010
  165. 165. Não é mais demorado? Saturday, March 20, 2010
  166. 166. Produtividade Cowboy Profissional Saturday, March 20, 2010
  167. 167. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Saturday, March 20, 2010
  168. 168. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Saturday, March 20, 2010
  169. 169. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Saturday, March 20, 2010
  170. 170. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Saturday, March 20, 2010
  171. 171. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Saturday, March 20, 2010
  172. 172. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Saturday, March 20, 2010
  173. 173. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Saturday, March 20, 2010
  174. 174. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Saturday, March 20, 2010
  175. 175. Produtividade Cowboy Profissional 70.00 52.50 Produtividade 35.00 17.50 0 1 2 3 4 5 6 7 8 Tempo Saturday, March 20, 2010
  176. 176. Saturday, March 20, 2010
  177. 177. Saturday, March 20, 2010
  178. 178. 237 Equipes 137 Finalizadas Saturday, March 20, 2010
  179. 179. Saturday, March 20, 2010
  180. 180. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Saturday, March 20, 2010
  181. 181. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Saturday, March 20, 2010
  182. 182. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Saturday, March 20, 2010
  183. 183. Empreendedorismo Código e “Forma” Ciclo de Vida de Projetos Comunidade Open Source Saturday, March 20, 2010
  184. 184. Pro ssionalismo Saturday, March 20, 2010
  185. 185. Saturday, March 20, 2010
  186. 186. Obrigado! akitaonrails.com Saturday, March 20, 2010

×