Rails advantages and
     techniques
Person.find_by_name ‘Jan’
• Jan ‘DefV’ De Poorter
• Developer, IT Engineer
• Openminds, #1 Rails Hoster in .be
• blog.defv.be
• Trying to be first on...
Ruby on Rails
Ruby on Rails
 it does scale
• Framework based on Ruby
• Fast, agile development
• www.rubyonrails.com
So... Why ?
“I already know PHP/.NET/...”
Fast Development
• CRUD
• Scaffolding (if you really need to)
• DRY
• AJAX
• acts_as_something
Maintainable
• Very readable code
• Implemented documentation system (RDOC)
• Tests makes sure you don’t break anything
Model View Controller
Model View Controller
• Interface to the database
• Business Logic goes here
• For the DataBase Admin
   class User < Acti...
Model View Controller
• Link between DB (model) and User (view)
• HTTP / Sessions / Cookies / Post / Get
• For the Develop...
Model View Controller
• Web Interface
• What the client sees
• For the Designer
   ...
   <body>
   <% @tasks.each do |tas...
Testing
Test-Driven Development
Test-Driven Development
• Write tests first
Test-Driven Development
• Write tests first
• FAIL
Test-Driven Development
• Write tests first
• FAIL
• Implement
Test-Driven Development
• Write tests first
• FAIL
• Implement
• SUCCEED
Test-Driven Development
• Write tests first
• FAIL
• Implement
• SUCCEED
• Clean Up
Test-Driven Development
• Write tests first
• FAIL
• Implement
• SUCCEED
• Clean Up
• Check-In to Version Management
that seems more work?
no
no (but..)
• No, because
  •   No more broken builds

  •   Fix bugs forever

  •   Think before you implement

  •   Small steps


•...
Not only for developers!
def test_if_layout_elements_are_present
 assert_select “body” do
   assert_select “div.task”, :count => 3 do
    assert_se...
is that all ?
No!
polymorphism




               No!
polymorphism
               20.minutes.ago




                    No!
polymorphism
               20.minutes.ago



1.gigabyte
                    No!
polymorphism
               20.minutes.ago



1.gigabyte
                    No!

                 time_ago_in_words
polymorphism
               20.minutes.ago



1.gigabyte
                    No!
   prototype

                 time_ago_i...
polymorphism
               20.minutes.ago
                         has_and_belongs_to_many

1.gigabyte
                  ...
polymorphism
               20.minutes.ago
                         has_and_belongs_to_many

1.gigabyte
                  ...
polymorphism
               20.minutes.ago
                         has_and_belongs_to_many

1.gigabyte
                  ...
link_to_remote
polymorphism
               20.minutes.ago
                         has_and_belongs_to_many

1.gigabyte
   ...
link_to_remote
polymorphism
               20.minutes.ago
                         has_and_belongs_to_many
  <%= debug obj...
link_to_remote
polymorphism
               20.minutes.ago
                         has_and_belongs_to_many
  <%= debug obj...
link_to_remote
polymorphism
               20.minutes.ago
                         has_and_belongs_to_many
  <%= debug obj...
link_to_remote
polymorphism
               20.minutes.ago
                         has_and_belongs_to_many
  <%= debug obj...
link_to_remote
polymorphism
               20.minutes.ago
                         has_and_belongs_to_many
  <%= debug obj...
titleize     link_to_remote
polymorphism
               20.minutes.ago
                          has_and_belongs_to_many
 ...
titleize     link_to_remote
polymorphism
               20.minutes.ago
                             has_and_belongs_to_man...
Q &A
   Examples?
   Discussion

   Thank you for listening
Jan De Poorter - Openminds
Upcoming SlideShare
Loading in …5
×

Rails advantages and techniques

6,548 views

Published on

Introduction to rails, and much used techniques, I presented at barcampbrussels

Published in: Business, Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,548
On SlideShare
0
From Embeds
0
Number of Embeds
167
Actions
Shares
0
Downloads
260
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Rails advantages and techniques

  1. 1. Rails advantages and techniques
  2. 2. Person.find_by_name ‘Jan’
  3. 3. • Jan ‘DefV’ De Poorter • Developer, IT Engineer • Openminds, #1 Rails Hoster in .be • blog.defv.be • Trying to be first on google as Jan
  4. 4. Ruby on Rails
  5. 5. Ruby on Rails it does scale
  6. 6. • Framework based on Ruby • Fast, agile development • www.rubyonrails.com
  7. 7. So... Why ? “I already know PHP/.NET/...”
  8. 8. Fast Development
  9. 9. • CRUD • Scaffolding (if you really need to) • DRY • AJAX • acts_as_something
  10. 10. Maintainable
  11. 11. • Very readable code • Implemented documentation system (RDOC) • Tests makes sure you don’t break anything
  12. 12. Model View Controller
  13. 13. Model View Controller • Interface to the database • Business Logic goes here • For the DataBase Admin class User < ActiveRecord::Base has_many :tasks end class Task < ActiveRecord::Base belongs_to :user end
  14. 14. Model View Controller • Link between DB (model) and User (view) • HTTP / Sessions / Cookies / Post / Get • For the Developer class TaskController < ApplicationController def index @tasks = User.find(session[:user_id]).tasks end end
  15. 15. Model View Controller • Web Interface • What the client sees • For the Designer ... <body> <% @tasks.each do |task| %> <div class=’task’> <%= task.content %> is <%= task.status %> </div> <% end %> </body>
  16. 16. Testing
  17. 17. Test-Driven Development
  18. 18. Test-Driven Development • Write tests first
  19. 19. Test-Driven Development • Write tests first • FAIL
  20. 20. Test-Driven Development • Write tests first • FAIL • Implement
  21. 21. Test-Driven Development • Write tests first • FAIL • Implement • SUCCEED
  22. 22. Test-Driven Development • Write tests first • FAIL • Implement • SUCCEED • Clean Up
  23. 23. Test-Driven Development • Write tests first • FAIL • Implement • SUCCEED • Clean Up • Check-In to Version Management
  24. 24. that seems more work?
  25. 25. no
  26. 26. no (but..)
  27. 27. • No, because • No more broken builds • Fix bugs forever • Think before you implement • Small steps • Yes, because • it takes time to learn
  28. 28. Not only for developers!
  29. 29. def test_if_layout_elements_are_present assert_select “body” do assert_select “div.task”, :count => 3 do assert_select “ul” do assert_select “li”, :count => 3 end end end end
  30. 30. is that all ?
  31. 31. No!
  32. 32. polymorphism No!
  33. 33. polymorphism 20.minutes.ago No!
  34. 34. polymorphism 20.minutes.ago 1.gigabyte No!
  35. 35. polymorphism 20.minutes.ago 1.gigabyte No! time_ago_in_words
  36. 36. polymorphism 20.minutes.ago 1.gigabyte No! prototype time_ago_in_words
  37. 37. polymorphism 20.minutes.ago has_and_belongs_to_many 1.gigabyte No! prototype time_ago_in_words
  38. 38. polymorphism 20.minutes.ago has_and_belongs_to_many 1.gigabyte No! cache prototype time_ago_in_words
  39. 39. polymorphism 20.minutes.ago has_and_belongs_to_many 1.gigabyte No! routes cache prototype time_ago_in_words
  40. 40. link_to_remote polymorphism 20.minutes.ago has_and_belongs_to_many 1.gigabyte No! routes cache prototype time_ago_in_words
  41. 41. link_to_remote polymorphism 20.minutes.ago has_and_belongs_to_many <%= debug object %> 1.gigabyte No! routes cache prototype time_ago_in_words
  42. 42. link_to_remote polymorphism 20.minutes.ago has_and_belongs_to_many <%= debug object %> 1.gigabyte No! routes cache prototype delegate time_ago_in_words
  43. 43. link_to_remote polymorphism 20.minutes.ago has_and_belongs_to_many <%= debug object %> 1.gigabyte No! routes group_by cache prototype delegate time_ago_in_words
  44. 44. link_to_remote polymorphism 20.minutes.ago has_and_belongs_to_many <%= debug object %> 1.gigabyte No! routes find_by_sql group_by cache prototype delegate time_ago_in_words
  45. 45. link_to_remote polymorphism 20.minutes.ago has_and_belongs_to_many <%= debug object %> 1.gigabyte REST No! routes find_by_sql group_by cache prototype delegate time_ago_in_words
  46. 46. titleize link_to_remote polymorphism 20.minutes.ago has_and_belongs_to_many <%= debug object %> 1.gigabyte REST No! routes find_by_sql group_by cache prototype delegate time_ago_in_words
  47. 47. titleize link_to_remote polymorphism 20.minutes.ago has_and_belongs_to_many <%= debug object %> 1.gigabyte REST No! routes ... find_by_sql group_by cache prototype delegate time_ago_in_words
  48. 48. Q &A Examples? Discussion Thank you for listening Jan De Poorter - Openminds

×