Rails - EXATEC2009
-
Upload
caue-guerra -
Category
Technology
-
view
410 -
download
0
description
Transcript of Rails - EXATEC2009
2009, ano do Ruby on Rails no Brasil
Ruby
Yukihiro Matsumoto (Matz)
“Often people, especially computer engineers, focus on the machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.”
Características
Orientada a Objetos 2.times { puts “Olá” }
Características
Orientada a Objetos
Tipagem dinâmica
2.times { puts “Olá” }
@nome = “Cauê Guerra”
Características
Orientada a Objetos
Tipagem dinâmica
2.times { puts “Olá” }
@nome = “Cauê Guerra”
Características
Meta-programação Código que gera código
Orientada a Objetos
Tipagem dinâmica
2.times { puts “Olá” }
@nome = “Cauê Guerra”
Características
Meta-programação
Programação funcional
Código que gera código
Exemplo
class CalculadorDeMDC { public int calcula(int a, int b) { if (b == 0) return a; else return calcula(b, a % b); }}
CalculadorDeMDC calculador = new CalculadorDeMDC();System.out.println(calculador.calcula(28, 7));
Java
class CalculadorDeMDC { def calcula(a: Int, b: Int): Int = { if (b == 0) a else calcula(b, a % b) }}
Scala
val calculador = new CalculadorDeMDCprintln(calculador.calcula(28, 7))
Ruby
class CalculadorDeMDC def calcula(a, b) if b == 0 a else calcula(b, a % b) end endend
calculador = CalculadorDeMDC.newputs calculador.calcula(28, 7)
Um outro exemplo
public String[] paraMaiuscula(String[] palavras) { String[] resposta = new String[palavras.length]; for (int i = 0; i < palavras.length; i++) resposta[i] = palavras[i].toUpperCase(); return resposta;}
Java
Ruby
def paraMaiuscula(palavras) palavras.map { |palavra| palavra.upcase }end
“Tornar as coisas simples, fáceis; e as complexas,
possíveis”Filosofia Ruby
1995
2001
Dave Thomas
Thomas Enebo
JRuby
Ruby escrito 100% em Java
2006
WTF?!?
WTF?!?
Pilares
Convention over Configuration
CoC
DRYDon’t Repeat Yourself
MVC
Browser
Browser
ApplicationController
Browser
ApplicationController
Controller
Browser
ApplicationController
Controller Model
Browser
ApplicationController
Controller Model
DB
Browser
ApplicationController
Controller Model
DB
Browser
ApplicationController
Controller Model
DB
Browser
ApplicationController
Controller Model
DBView
AplicaçãoConfiguraçõesSchema evolution
Testes
Model
View
Controller
Testes
TestesTest All The Fucking Time!
TDDBDD
Test Driven Development
Behavior Driven Development
it "should require acceptance of terms of service" do @job.attributes = valid_job_attributes.except(:terms_accepted) @job.should_not be_valid @job.terms_accepted = false @job.should_not be_valid @job.terms_accepted = true @job.should be_validend
RSpec
Feature: Job listing In order to see the job offers in my area and start working As a user I want to see a list of jobs filtered by type and location
Scenario: Listing when there is no jobs Given there is no jobs When I go to "java" Then I should see "Desculpe, não existem vagas disponíveis." And the "OndeTrabalhar.com" field should contain "java"
Cucumber
Rails não escala!
Hoje o Redeparede.com serve 7,5 milhões de acessos por mês usando Ruby on Rails. Rails escala, depende de você!
“Basecamp is now handling more than 50 million Rails requests per week. We're peaking out at around 200
req/sec. Damn!”
“Basecamp's average response time is 90ms and 87% of all requests
finish in less than 200ms.”
Não conheço ninguém que use Rails
Rails 3 = +
Yehuda Katz
José Valim
Regis Pires
IFPI - Piauí
2
3
Formação Rails
RR-71: Desenvolvimento Ágil para Web 2.0 com Ruby on Rails
RR-75: Ruby e Rails avançados: lidando com problemas do dia a dia
0
38
75
113
150
10
72
113
2007
2008
2009
E daí?
http://ondetrabalhar.com/ruby+ou+rails