Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Desenvolvimento Ágil com Ruby on Rails

Desenvolvimento Ágil com Ruby on Rails

Palestra sobre desenvolvimento ágil com RoR realizado na Meet2Brains de Abril/2013.

A palestra teve a intenção de mostrar como e porque o RoR permite o desenvolvimento ágil.

Almir Mendes

April 29, 2013
Tweet

More Decks by Almir Mendes

Other Decks in Programming

Transcript

  1. "Programmers should always be interested in learning new languages, preferably

    from an unfamiliar paradigm" "97 Things Every Programmer Should Know" terça-feira, 30 de abril de 13
  2. Uso de Blocos my_list = [1,2,3,4,5] my_list.each do |item| #

    deal with item end terça-feira, 30 de abril de 13
  3. Tudo tem valor x = 10 y = 11 z

    = if x < y 1 else 2 end z # => 1 terça-feira, 30 de abril de 13
  4. Tudo é objeto 10.times{ |n| puts n } 10.class =>

    Fixnum terça-feira, 30 de abril de 13
  5. Tudo é objeto 10.times{ |n| puts n } 10.class =>

    Fixnum Fixnum.class => Class terça-feira, 30 de abril de 13
  6. Tudo é objeto 10.times{ |n| puts n } 10.class =>

    Fixnum Fixnum.class => Class Fixnum.ancestors => [Fixnum, Integer, Numeric, Comparable, Object, Kernel, BasicObject] terça-feira, 30 de abril de 13
  7. # This 1 + 2 # Is the same as

    this ... 1.+(2) # Which is the same as this: 1.send "+", 2 terça-feira, 30 de abril de 13
  8. # This 1 + 2 # Is the same as

    this ... 1.+(2) # Which is the same as this: 1.send "+", 2 terça-feira, 30 de abril de 13
  9. class Car def inspect “Cheap car” end end other_car =

    Car.new other_car.inspect # => “Cheap car” terça-feira, 30 de abril de 13
  10. class Car def inspect “Cheap car” end end other_car =

    Car.new other_car.inspect # => “Cheap car” terça-feira, 30 de abril de 13
  11. class Car def inspect “Cheap car” end end porsche =

    Car.new porsche.inspect # => “Cheap car” def porsche.inspect “Expensive car” end porsche.inspect # => “Expensive car” other_car = Car.new other_car.inspect # => “Cheap car” terça-feira, 30 de abril de 13
  12. class Car def inspect “Cheap car” end end porsche =

    Car.new porsche.inspect # => “Cheap car” def porsche.inspect “Expensive car” end porsche.inspect # => “Expensive car” other_car = Car.new other_car.inspect # => “Cheap car” terça-feira, 30 de abril de 13
  13. class Fixnum def hours self * 3600 # number of

    seconds/hour end alias hour hours end # 14 hours from 00:00 January 1st Time.mktime(2006, 01, 01) + 14.hours # => Sun Jan 01 14:00:00 terça-feira, 30 de abril de 13
  14. class Fixnum def hours self * 3600 # number of

    seconds/hour end alias hour hours end # 14 hours from 00:00 January 1st Time.mktime(2006, 01, 01) + 14.hours # => Sun Jan 01 14:00:00 Time.mktime(2006, 01, 01) + 14.hours # => Sun Jan 01 14:00:00 terça-feira, 30 de abril de 13
  15. class Fixnum def hours self * 3600 # number of

    seconds/hour end alias hour hours end # 14 hours from 00:00 January 1st Time.mktime(2006, 01, 01) + 14.hours # => Sun Jan 01 14:00:00 Time.mktime(2006, 01, 01) + 14.hours # => Sun Jan 01 14:00:00 terça-feira, 30 de abril de 13
  16. Layouts, Views, Partials # application.html.erb <html> <body> <%= yield %>

    </body> </html # clientes/index.html.erb <h1>Clientes</h1> <table> ... </table> terça-feira, 30 de abril de 13
  17. Helpers FORMS, TAGS, HTML BLOCKS, SUPPORT, FORMATS, ... <%= form_for

    @article do |f| %> <%= f.text_field :title %> <%= f.text_area :body, size: "60x12" %> <%= f.submit "Create" %> <% end %> terça-feira, 30 de abril de 13
  18. Model - Scope @published = Post.where(published: true) class Post <

    ActiveRecord::Base scope :published, where(published: true) end terça-feira, 30 de abril de 13
  19. Model - Scope @published = Post.where(published: true) class Post <

    ActiveRecord::Base scope :published, where(published: true) end @published = Post.published terça-feira, 30 de abril de 13
  20. 1 2 3 4 5 6 7 8 9 10

    11 12 13 14 15 16 17 18 19 20 21 #config/routes.rb resources :posts #app/controllers/posts_controller.rb class PostsController < ApplicationController def index @posts = Post.published end # ... end #app/views/posts/index.html.erb <h1>Posts</h1> <ul> <%= render @posts %> </ul> #app/views/posts/_post.html.erb <li><%= post.title %></li> terça-feira, 30 de abril de 13
  21. Migrations Migrations are a convenient way for you to alter

    your database in a structured and organized manner terça-feira, 30 de abril de 13
  22. class CreateProducts < ActiveRecord::Migration def up create_table :products do |t|

    t.string :name t.text :description t.timestamps end end def down drop_table :products end end terça-feira, 30 de abril de 13
  23. Extensível Autenticação, paginação, manipulação/upload de imagens, webservice, privilégios, pdf, csv,

    xml, json, filas, monitoramento, database drivers, ... terça-feira, 30 de abril de 13