Ruby on Rails
Friday, August 7, 2009
AkitaOnRails.com
            slideshare.net/akitaonrails




Friday, August 7, 2009
2008
Friday, August 7, 2009
2008
Friday, August 7, 2009
13 e 14
                         Outubro

                         2009
Friday, August 7, 2009
Friday, August 7, 2009
~140 slides
                          ~45 min


Friday, August 7, 2009
www.slideshare.net/akitaonrails

                     fabio.akita@locaweb.com.br




Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Ruby on Rails         2.3

                         Ruby   1.8

                 Novo Ruby      1.9
Friday, August 7, 2009
Ruby on Rails         2.3

                         Ruby   1.8

                 Novo Ruby      1.9
Friday, August 7, 2009
Ruby on Rails         2.3

                         Ruby   1.8

                 Novo Ruby      1.9
Friday, August 7, 2009
“Matz”




                         1993
Friday, August 7, 2009
Friday, August 7, 2009
“Prag Dave”




                         2001
Friday, August 7, 2009
Friday, August 7, 2009
“DHH”



                          2004
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Charles Nutter



                              2006
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
“Tornar as coisas
               simples fáceis e as
                coisas complexas
                    possíveis”
     ...
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
O que dizem
                           por aí ...


Friday, August 7, 2009
Pouco usado



Friday, August 7, 2009
Rails não Escala



Friday, August 7, 2009
Ruby é Lento



Friday, August 7, 2009
WTF!?

Friday, August 7, 2009
Pouco usado



Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Rails não Escala



Friday, August 7, 2009
Friday, August 7, 2009
Blaine Cook

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


Friday, Au...
Para colocar as coisas em
      perspectiva, o Friendster foi
          escrito em Java e eles
      mudaram para PHP. MyS...
Para colocar as coisas em
      perspectiva, o Friendster foi
          escrito em Java e eles
      mudaram para PHP. MyS...
“O The New York Times usou Ruby on Rails para
               agregar, analizar e mostrar os resultados das
             el...
“O The New York Times usou Ruby on Rails para
               agregar, analizar e mostrar os resultados das
             el...
Ruby é Lento



Friday, August 7, 2009
x mais lento que C++




Friday, August 7, 2009
x mais lento que C++
                         0
                             50
                                          ...
Homepage: 331 ms




Friday, August 7, 2009
Homepage: 331 ms

                         Total: 5.45 s
Friday, August 7, 2009
Friday, August 7, 2009
Performance
                              !=
                         Escalabilidade

Friday, August 7, 2009
Ruby on Rails



Friday, August 7, 2009
Friday, August 7, 2009
Código que gera Código


                 Convention over Configuration


                          Don’t Repeat Yourself
...
Código que gera Código


                 Convention over Configuration


                          Don’t Repeat Yourself
...
Código que gera Código


                 Convention over Configuration


                          Don’t Repeat Yourself
...
Código que gera Código


                 Convention over Configuration


                          Don’t Repeat Yourself
...
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Model

   class Product < ActiveRecord::Base
     after_create :set_initial_inventory

       has_many :variants, :depende...
Model

   class Product < ActiveRecord::Base
     after_create :set_initial_inventory

       has_many :variants, :depende...
Model

   class Product < ActiveRecord::Base
     after_create :set_initial_inventory

       has_many :variants, :depende...
Model

   class Product < ActiveRecord::Base
     after_create :set_initial_inventory

       has_many :variants, :depende...
Model

   class Product < ActiveRecord::Base
     after_create :set_initial_inventory

       has_many :variants, :depende...
Model

   class Product < ActiveRecord::Base
     after_create :set_initial_inventory

       has_many :variants, :depende...
Model

   class Product < ActiveRecord::Base
     after_create :set_initial_inventory

       has_many :variants, :depende...
Model

   class Product < ActiveRecord::Base
     after_create :set_initial_inventory

       has_many :variants, :depende...
Model

   class Product < ActiveRecord::Base
     after_create :set_initial_inventory

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



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

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



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

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



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

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



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

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



                  GET /products/new
   ActionController::Routing::Routes.draw do |map|
                  ...
Controller

    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_ex...
Controller

    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_ex...
Controller

    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_ex...
Controller

    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_ex...
Controller

    class UsersController < Spree::BaseController
      resource_controller
      before_filter :initialize_ex...
Migrations


        class RenameAppConfiguration < ActiveRecord::Migration
          def self.up
            rename_table...
Migrations


        class RenameAppConfiguration < ActiveRecord::Migration
          def self.up
            rename_table...
Migrations


        class RenameAppConfiguration < ActiveRecord::Migration
          def self.up
            rename_table...
Migrations


        class RenameAppConfiguration < ActiveRecord::Migration
          def self.up
            rename_table...
Migrations


        class RenameAppConfiguration < ActiveRecord::Migration
          def self.up
            rename_table...
Open Source



Friday, August 7, 2009
Friday, August 7, 2009
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
          ...
Friday, August 7, 2009
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
                ...
Before do
   @calc = Calculadora.new
 end

 Dado /que eu digitei (d+) na calculadora/ do |n|
   @calc.push n.to_i
 end

 Q...
Before do
   @calc = Calculadora.new
 end

 Dado /que eu digitei (d+) na calculadora/ do |n|
   @calc.push n.to_i
 end

 Q...
Before do
   @calc = Calculadora.new
 end

 Dado /que eu digitei (d+) na calculadora/ do |n|
   @calc.push n.to_i
 end

 Q...
Before do
   @calc = Calculadora.new
 end

 Dado /que eu digitei (d+) na calculadora/ do |n|
   @calc.push n.to_i
 end

 Q...
class SignupTest < ActionController::IntegrationTest

               def test_trial_account_sign_up
                 visit...
Friday, August 7, 2009
rspec             rspec.info

            cucumber                cukes.info

               shoulda    thoughtbot.com/pro...
• plugins de Active Record
                • plugins de Views
                • plugins de Localização
                • C...
“Beautiful Code”



Friday, August 7, 2009
@Transient
                                                                 public BigDecimal getTotal()
       //$Id: Boo...
public int getBeds()
  public void setUser(User user)
                                                                    ...
class Booking < ActiveRecord::Base
                belongs_to :hotel
                belongs_to :user
                vali...
class Booking < ActiveRecord::Base
                belongs_to :hotel
                belongs_to :user
                vali...
class CreateBookings < ActiveRecord::Migration
                           def self.up
                             create_...
class CreateBookings < ActiveRecord::Migration
                           def self.up
                             create_...
class CreateBookings < ActiveRecord::Migration
                           def self.up
                             create_...
190
                         vs
                         40

Friday, August 7, 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 ...
“Eles servem mais de 23 milhões de visitantes/mês. A conversão resultou em
               20 mil linhas de Ruby em vez de ...
“Eles servem mais de 23 milhões de visitantes/mês. A conversão resultou em
               20 mil linhas de Ruby em vez de ...
“Eles servem mais de 23 milhões de visitantes/mês. A conversão resultou em
               20 mil linhas de Ruby em vez de ...
Friday, August 7, 2009
11 mil
                         classes!

                         46 só de
                         coleções!


Friday, A...
• Classes:
                         • Modules:       • Array
                          • Enumerable    • Hash
            ...
1.400 Classes:
                                      •
                                 classesArray
                     ...
Mitos?



Friday, August 7, 2009
Friday, August 7, 2009
Mais Produtivo




                           “Melhor”




                          Anti-legado


Friday, August 7, 2009
Mais Produtivo




                           “Melhor”




                          Anti-legado


Friday, August 7, 2009
Mais Produtivo




                           “Melhor”




                          Anti-legado


Friday, August 7, 2009
Agilidade



Friday, August 7, 2009
Friday, August 7, 2009
Robert C. Martin


Friday, August 7, 2009
“Uncle Bob”

Friday, August 7, 2009
Código Limpo



Friday, August 7, 2009
Friday, August 7, 2009
Test Driven
                         Development


Friday, August 7, 2009
Friday, August 7, 2009
Ferramentas
                            Ágeis


Friday, August 7, 2009
Gerenciamento



Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Repositórios



Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Integração
                          Contínua


Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Deployment



Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Monitoramento



Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Comunidade



Friday, August 7, 2009
peepcode.com




                                        Geoffrey
Friday, August 7, 2009
railsenvy.com




                                         Jason e Gregg
Friday, August 7, 2009
railscasts.com




                                          Ryan Bates
Friday, August 7, 2009
guias.rubyonrails.pro.br




                                               Pratik Naik
Friday, August 7, 2009
rubylearning.org




                                            Satish Talim
Friday, August 7, 2009
rubyinside.com.br




                                             Peter Cooper
Friday, August 7, 2009
why.nomedojogo.com




                                              _why
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Friday, August 7, 2009
Obrigado!
                          akitaonrails.com




Friday, August 7, 2009
Upcoming SlideShare
Loading in...5
×

Oxente on Rails 2009

678

Published on

Mais uma introdução à filosofia das comunidades Ruby e Rails, com ênfase no Ecossistema mais do que na Tecnologia.

Vídeo da 37signals: http://www.vimeo.com/6028818

Vídeo do Uncle Bob: http://www.vimeo.com/5196176

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
678
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
27
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Oxente on Rails 2009

  1. 1. Ruby on Rails Friday, August 7, 2009
  2. 2. AkitaOnRails.com slideshare.net/akitaonrails Friday, August 7, 2009
  3. 3. 2008 Friday, August 7, 2009
  4. 4. 2008 Friday, August 7, 2009
  5. 5. 13 e 14 Outubro 2009 Friday, August 7, 2009
  6. 6. Friday, August 7, 2009
  7. 7. ~140 slides ~45 min Friday, August 7, 2009
  8. 8. www.slideshare.net/akitaonrails fabio.akita@locaweb.com.br Friday, August 7, 2009
  9. 9. Friday, August 7, 2009
  10. 10. Friday, August 7, 2009
  11. 11. Friday, August 7, 2009
  12. 12. Ruby on Rails 2.3 Ruby 1.8 Novo Ruby 1.9 Friday, August 7, 2009
  13. 13. Ruby on Rails 2.3 Ruby 1.8 Novo Ruby 1.9 Friday, August 7, 2009
  14. 14. Ruby on Rails 2.3 Ruby 1.8 Novo Ruby 1.9 Friday, August 7, 2009
  15. 15. “Matz” 1993 Friday, August 7, 2009
  16. 16. Friday, August 7, 2009
  17. 17. “Prag Dave” 2001 Friday, August 7, 2009
  18. 18. Friday, August 7, 2009
  19. 19. “DHH” 2004 Friday, August 7, 2009
  20. 20. Friday, August 7, 2009
  21. 21. Friday, August 7, 2009
  22. 22. Charles Nutter 2006 Friday, August 7, 2009
  23. 23. Friday, August 7, 2009
  24. 24. Friday, August 7, 2009
  25. 25. Friday, August 7, 2009
  26. 26. Friday, August 7, 2009
  27. 27. “Tornar as coisas simples fáceis e as coisas complexas possíveis” Filosofia Ruby Friday, August 7, 2009
  28. 28. Friday, August 7, 2009
  29. 29. Friday, August 7, 2009
  30. 30. Friday, August 7, 2009
  31. 31. Friday, August 7, 2009
  32. 32. O que dizem por aí ... Friday, August 7, 2009
  33. 33. Pouco usado Friday, August 7, 2009
  34. 34. Rails não Escala Friday, August 7, 2009
  35. 35. Ruby é Lento Friday, August 7, 2009
  36. 36. WTF!? Friday, August 7, 2009
  37. 37. Pouco usado Friday, August 7, 2009
  38. 38. Friday, August 7, 2009
  39. 39. Friday, August 7, 2009
  40. 40. Friday, August 7, 2009
  41. 41. Friday, August 7, 2009
  42. 42. Friday, August 7, 2009
  43. 43. Friday, August 7, 2009
  44. 44. Friday, August 7, 2009
  45. 45. Friday, August 7, 2009
  46. 46. Friday, August 7, 2009
  47. 47. Friday, August 7, 2009
  48. 48. Friday, August 7, 2009
  49. 49. Rails não Escala Friday, August 7, 2009
  50. 50. Friday, August 7, 2009
  51. 51. Blaine Cook http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter Friday, August 7, 2009
  52. 52. 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 Friday, August 7, 2009
  53. 53. 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 Friday, August 7, 2009
  54. 54. “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 Friday, August 7, 2009
  55. 55. “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 Friday, August 7, 2009
  56. 56. Ruby é Lento Friday, August 7, 2009
  57. 57. x mais lento que C++ Friday, August 7, 2009
  58. 58. x mais lento que C++ 0 50 100 Python 2 150 Ruby 1.9 200 Perl JRuby Python 3 PHP Ruby 1.8.6 Friday, August 7, 2009
  59. 59. Homepage: 331 ms Friday, August 7, 2009
  60. 60. Homepage: 331 ms Total: 5.45 s Friday, August 7, 2009
  61. 61. Friday, August 7, 2009
  62. 62. Performance != Escalabilidade Friday, August 7, 2009
  63. 63. Ruby on Rails Friday, August 7, 2009
  64. 64. Friday, August 7, 2009
  65. 65. Código que gera Código Convention over Configuration Don’t Repeat Yourself Extreme Programming Friday, August 7, 2009
  66. 66. Código que gera Código Convention over Configuration Don’t Repeat Yourself Extreme Programming Friday, August 7, 2009
  67. 67. Código que gera Código Convention over Configuration Don’t Repeat Yourself Extreme Programming Friday, August 7, 2009
  68. 68. Código que gera Código Convention over Configuration Don’t Repeat Yourself Extreme Programming Friday, August 7, 2009
  69. 69. Friday, August 7, 2009
  70. 70. Friday, August 7, 2009
  71. 71. Friday, August 7, 2009
  72. 72. Friday, August 7, 2009
  73. 73. Friday, August 7, 2009
  74. 74. Friday, August 7, 2009
  75. 75. Friday, August 7, 2009
  76. 76. Friday, August 7, 2009
  77. 77. Friday, August 7, 2009
  78. 78. Friday, August 7, 2009
  79. 79. Friday, August 7, 2009
  80. 80. Friday, August 7, 2009
  81. 81. Friday, August 7, 2009
  82. 82. Friday, August 7, 2009
  83. 83. 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 Friday, August 7, 2009
  84. 84. 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 Friday, August 7, 2009
  85. 85. 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 Friday, August 7, 2009
  86. 86. 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 Friday, August 7, 2009
  87. 87. 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 Friday, August 7, 2009
  88. 88. 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 Friday, August 7, 2009
  89. 89. 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 Friday, August 7, 2009
  90. 90. 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 Friday, August 7, 2009
  91. 91. 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 Product.find(1) belongs_to :tax_category validates_presence_of :name validates_presence_of :master_price validates_presence_of :description make_permalink :with => :name, :field => :permalink end Friday, August 7, 2009
  92. 92. 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? %> Friday, August 7, 2009
  93. 93. 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? %> Friday, August 7, 2009
  94. 94. 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? %> Friday, August 7, 2009
  95. 95. 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 Friday, August 7, 2009
  96. 96. 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 Friday, August 7, 2009
  97. 97. 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 Friday, August 7, 2009
  98. 98. 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 Friday, August 7, 2009
  99. 99. Rotas RESTFul GET /products/new ActionController::Routing::Routes.draw do |map| GET /products POST /products map.resources :products map.resources :addresses map.resourcesGET /products/1 => [:line_items] :orders, :has_many map.namespaceGET /products/1/edit :admin do |admin| PUT /products/1 admin.resources :users admin.resources :products end DESTROY /products/1 end Friday, August 7, 2009
  100. 100. 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 Friday, August 7, 2009
  101. 101. 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 Friday, August 7, 2009
  102. 102. 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 Friday, August 7, 2009
  103. 103. 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 Friday, August 7, 2009
  104. 104. 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) /users/1 .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 Friday, August 7, 2009
  105. 105. Migrations class RenameAppConfiguration < ActiveRecord::Migration def self.up rename_table :app_configurations, :configurations change_table :configurations do |t| t.string :type end end def self.down change_table :configurations do |t| t.remove :type end rename_table :configurations, :app_configurations end end Friday, August 7, 2009
  106. 106. Migrations class RenameAppConfiguration < ActiveRecord::Migration def self.up rename_table :app_configurations, :configurations change_table :configurations do |t| t.string :type end end def self.down change_table :configurations do |t| t.remove :type end rename_table :configurations, :app_configurations end end Friday, August 7, 2009
  107. 107. Migrations class RenameAppConfiguration < ActiveRecord::Migration def self.up rename_table :app_configurations, :configurations change_table :configurations do |t| t.string :type end end def self.down change_table :configurations do |t| t.remove :type end rename_table :configurations, :app_configurations end end Friday, August 7, 2009
  108. 108. Migrations class RenameAppConfiguration < ActiveRecord::Migration def self.up rename_table :app_configurations, :configurations change_table :configurations do |t| t.string :type end end def self.down change_table :configurations do |t| t.remove :type end rename_table :configurations, :app_configurations end end Friday, August 7, 2009
  109. 109. Migrations class RenameAppConfiguration < ActiveRecord::Migration def self.up rename_table :app_configurations, :configurations change_table :configurations do |t| t.string :type end end rake db:migrate def self.down change_table :configurations do |t| t.remove :type end rename_table :configurations, :app_configurations end end Friday, August 7, 2009
  110. 110. Open Source Friday, August 7, 2009
  111. 111. Friday, August 7, 2009
  112. 112. 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 Friday, August 7, 2009
  113. 113. 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 Friday, August 7, 2009
  114. 114. 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 Friday, August 7, 2009
  115. 115. 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 Friday, August 7, 2009
  116. 116. Friday, August 7, 2009
  117. 117. 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 Friday, August 7, 2009
  118. 118. 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 Friday, August 7, 2009
  119. 119. Before do @calc = Calculadora.new end Dado /que eu digitei (d+) na calculadora/ do |n| @calc.push n.to_i end Quando 'eu aperto o botão de soma' do @result = @calc.soma end Então /o resultado na calculadora deve ser (d*)/ do |result| @result.should == result.to_i end Friday, August 7, 2009
  120. 120. Before do @calc = Calculadora.new end Dado /que eu digitei (d+) na calculadora/ do |n| @calc.push n.to_i end Quando 'eu aperto o botão de soma' do @result = @calc.soma end Então /o resultado na calculadora deve ser (d*)/ do |result| @result.should == result.to_i end Friday, August 7, 2009
  121. 121. Before do @calc = Calculadora.new end Dado /que eu digitei (d+) na calculadora/ do |n| @calc.push n.to_i end Quando 'eu aperto o botão de soma' do @result = @calc.soma end Então /o resultado na calculadora deve ser (d*)/ do |result| @result.should == result.to_i end Friday, August 7, 2009
  122. 122. Before do @calc = Calculadora.new end Dado /que eu digitei (d+) na calculadora/ do |n| @calc.push n.to_i end Quando 'eu aperto o botão de soma' do @result = @calc.soma end Então /o resultado na calculadora deve ser (d*)/ do |result| @result.should == result.to_i end Friday, August 7, 2009
  123. 123. class SignupTest < ActionController::IntegrationTest def test_trial_account_sign_up visit home_path click_link "Sign up" fill_in "Email", :with => "good@example.com" select "Free account" click_button "Register" end end Friday, August 7, 2009
  124. 124. Friday, August 7, 2009
  125. 125. rspec rspec.info cucumber cukes.info shoulda thoughtbot.com/projects/shoulda webrat github.com/brynary/webrat integrity integrityapp.com ZenTest zenspider.com Friday, August 7, 2009
  126. 126. • plugins de Active Record • plugins de Views • plugins de Localização • CMS • Parsers • Autenticadores/Autorizadores Friday, August 7, 2009
  127. 127. “Beautiful Code” Friday, August 7, 2009
  128. 128. @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; } Friday, August 7, 2009
  129. 129. 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; } } Friday, August 7, 2009
  130. 130. 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 Friday, August 7, 2009
  131. 131. 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 Friday, August 7, 2009
  132. 132. 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 Friday, August 7, 2009
  133. 133. 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 Friday, August 7, 2009
  134. 134. 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 Friday, August 7, 2009
  135. 135. 190 vs 40 Friday, August 7, 2009
  136. 136. “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 Friday, August 7, 2009
  137. 137. “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 Friday, August 7, 2009
  138. 138. “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 Friday, August 7, 2009
  139. 139. “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 Friday, August 7, 2009
  140. 140. Friday, August 7, 2009
  141. 141. 11 mil classes! 46 só de coleções! Friday, August 7, 2009
  142. 142. • Classes: • Modules: • Array • Enumerable • Hash • Comparable • Set • Sorted Set Friday, August 7, 2009
  143. 143. 1.400 Classes: • classesArray • Modules: • • Enumerable • Hash • Comparable 6 de Set só • • Sorted coleções! Set Friday, August 7, 2009
  144. 144. Mitos? Friday, August 7, 2009
  145. 145. Friday, August 7, 2009
  146. 146. Mais Produtivo “Melhor” Anti-legado Friday, August 7, 2009
  147. 147. Mais Produtivo “Melhor” Anti-legado Friday, August 7, 2009
  148. 148. Mais Produtivo “Melhor” Anti-legado Friday, August 7, 2009
  149. 149. Agilidade Friday, August 7, 2009
  150. 150. Friday, August 7, 2009
  151. 151. Robert C. Martin Friday, August 7, 2009
  152. 152. “Uncle Bob” Friday, August 7, 2009
  153. 153. Código Limpo Friday, August 7, 2009
  154. 154. Friday, August 7, 2009
  155. 155. Test Driven Development Friday, August 7, 2009
  156. 156. Friday, August 7, 2009
  157. 157. Ferramentas Ágeis Friday, August 7, 2009
  158. 158. Gerenciamento Friday, August 7, 2009
  159. 159. Friday, August 7, 2009
  160. 160. Friday, August 7, 2009
  161. 161. Friday, August 7, 2009
  162. 162. Repositórios Friday, August 7, 2009
  163. 163. Friday, August 7, 2009
  164. 164. Friday, August 7, 2009
  165. 165. Integração Contínua Friday, August 7, 2009
  166. 166. Friday, August 7, 2009
  167. 167. Friday, August 7, 2009
  168. 168. Friday, August 7, 2009
  169. 169. Deployment Friday, August 7, 2009
  170. 170. Friday, August 7, 2009
  171. 171. Friday, August 7, 2009
  172. 172. Friday, August 7, 2009
  173. 173. Monitoramento Friday, August 7, 2009
  174. 174. Friday, August 7, 2009
  175. 175. Friday, August 7, 2009
  176. 176. Friday, August 7, 2009
  177. 177. Comunidade Friday, August 7, 2009
  178. 178. peepcode.com Geoffrey Friday, August 7, 2009
  179. 179. railsenvy.com Jason e Gregg Friday, August 7, 2009
  180. 180. railscasts.com Ryan Bates Friday, August 7, 2009
  181. 181. guias.rubyonrails.pro.br Pratik Naik Friday, August 7, 2009
  182. 182. rubylearning.org Satish Talim Friday, August 7, 2009
  183. 183. rubyinside.com.br Peter Cooper Friday, August 7, 2009
  184. 184. why.nomedojogo.com _why Friday, August 7, 2009
  185. 185. Friday, August 7, 2009
  186. 186. Friday, August 7, 2009
  187. 187. Friday, August 7, 2009
  188. 188. Friday, August 7, 2009
  189. 189. Friday, August 7, 2009
  190. 190. Friday, August 7, 2009
  191. 191. Friday, August 7, 2009
  192. 192. Obrigado! akitaonrails.com Friday, August 7, 2009
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×