Contenu connexe Similaire à Fórum de Software Livre do Serpro RJ 2009 (20) Fórum de Software Livre do Serpro RJ 200936. “Eu inventei o termo
ʻorientação a
objetosʼ, e posso
lhes dizer que eu
não estava
pensando em C++.”
Tuesday, September 15, 2009
63. 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, September 15, 2009
64. 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, September 15, 2009
65. 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, September 15, 2009
66. 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, September 15, 2009
67. 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, September 15, 2009
68. 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, September 15, 2009
69. 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, September 15, 2009
70. <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, September 15, 2009
71. <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, September 15, 2009
72. <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, September 15, 2009
73. #product-listing
=breadcrumbs(@taxon)
%br
=render :partial => "shared/products.html.erb",
:locals => {:products => @products, :taxon => @taxon}
-content_for :sidebar do
%td#shop-by-col(:valign => "top")
=render :partial => "shared/taxonomies"
=render :partial => 'shared/paginate',
:locals => {:collection => @products, :options => {}}
unless @products.empty?
Tuesday, September 15, 2009
75. @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, September 15, 2009
76. 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, September 15, 2009
77. 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, September 15, 2009
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, September 15, 2009
79. 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, September 15, 2009
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, September 15, 2009
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, September 15, 2009
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
Tuesday, September 15, 2009
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, September 15, 2009
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, September 15, 2009
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, September 15, 2009
117. Blaine Cook
http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter
Tuesday, September 15, 2009
118. 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, September 15, 2009
119. 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, September 15, 2009
120. “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, September 15, 2009
121. “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, September 15, 2009
124. 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, September 15, 2009
142. 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, September 15, 2009
143. 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, September 15, 2009
147. “Cowboy” Profissional
Tuesday, September 15, 2009
148. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
149. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
150. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
151. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
152. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
153. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
154. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
155. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
156. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
157. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
158. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
159. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
160. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
161. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
162. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
163. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
164. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
165. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
166. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
167. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009
168. “Cowboy” Profissional
70.00
52.50
Produtividade
35.00
17.50
0
1 2 3 4 5 6 7 8 9 10
Tempo
Tuesday, September 15, 2009