Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Rapid development with Rails

6,252 views

Published on

OSDC TW 2011 Rapid development with Rails

Published in: Technology
  • Be the first to comment

Rapid development with Rails

  1. 1. Rapid Development with Rails
  2. 2. About me• / xdite• using Rails since 2007• http://blog.xdite.net• xdite@techbang.com.tw
  3. 3. Lead Developer & Manager
  4. 4. • Rails• Rapid Development with Rails
  5. 5. Ruby on Rails• Since 2004, DHH from 37 signals• • DRY / Agile / Rapid / Cooooool !!• • Developer / / / ....
  6. 6. • Developer•••
  7. 7. ...
  8. 8. ...
  9. 9. Developer• PHP Developer• PHP Developer• Convention• Developer• Rails Developer
  10. 10. •••• Developer
  11. 11. •• Rails 3 > Django > Rails 2 > Zend > Symfony >>>>>> CakePHP•• 1M PV /day•
  12. 12. • • code • Test • Version Control )•
  13. 13. Rapid Development?•5 CRUD• XXX•
  14. 14. •••••
  15. 15. ..?
  16. 16. DELIVER
  17. 17. Rapid ?
  18. 18. FAIL!••••
  19. 19. development model
  20. 20. Rails
  21. 21. Rails••
  22. 22. Rails••
  23. 23. Rails•••• => =>
  24. 24. •••• do better• / solution
  25. 25. Rapid Development ?
  26. 26. Team Development
  27. 27. ••••
  28. 28. Team Development•• + = Team• Opensource plugin + = Team
  29. 29. Convention / Practices
  30. 30. Rails• Community-based best practices• Continuous revolution• contributed by top developers• cutting-edge technologies & ideas running on production• Online training courses provided by Google
  31. 31. Rails ....
  32. 32. { }
  33. 33. Rails• Community-based best practices• Continuous revolution• contributed by top developers• cutting-edge technologies & ideas running on production
  34. 34. !
  35. 35. Rails
  36. 36. Scaling Rails by Default http://slidesha.re/dkJjOB• Client-side Performance Tuning
  37. 37. • Client-side Performance Tuning • CDN
  38. 38. image_taghttp://asset.example.org/photos/small.jpg?1269316198
  39. 39. • Client-side Performance Tuning • CDN • Minimal HTTP Request
  40. 40. <%= javascript_include_tag :default, :cache => true %><%=stylesheet_link_tag “main”, :cache => true %>http://asset.example.org/javascripts/all.js?1269316198http://asset.example.org/stylesheets/all.css?1269316198
  41. 41. • Client-side Performance Tuning • CDN • Minimal HTTP Request • Parallel Download
  42. 42. config.action_controller.asset_host = “asset%d.example.org”http://asset1.example.org/javascripts/all.js?1269316198http://asset2.example.org/javascripts/all.js?1269316198http://asset3.example.org/javascripts/all.js?1269316198http://asset4.example.org/javascripts/all.js?1269316198
  43. 43. • Client-side Performance Tuning • CDN • Minimal HTTP Request • Parallel Download • Cache Control
  44. 44. def index do_somthing expires_in 10.minutesendheader[“Cache-Control”] = “max-age=600”
  45. 45. Scaling Rails by Default http://slidesha.re/dkJjOB• Client-side Performance Tunning • CDN • Minimal HTTP Request • Parallel Download • Cache Control • ETags, Last Modified.....etc
  46. 46. • Common sense of DB tuning
  47. 47. • Common sense of DB tuning • Avoid N+1 Query using “bullet” plugin , :include => [:comment]
  48. 48. • Common sense of DB tuning • Avoid N+1 Query • Use Counter Cache belongs_to :post, :counter_cache => “true”
  49. 49. • Common sense of DB tuning • Avoid N+1 Query • Use Counter Cache • Use CONSTANT CONSTANT will cache in memory
  50. 50. • Common sense of DB tuning • Avoid N+1 Query • Use Counter Cache • Use CONSTANT • ADD INDEX EXPLAIN every query, avoid table scan using “rails_index” plugin
  51. 51. • Common sense of DB tuning • Avoid N+1 Query • Use Counter Cache • Use CONSTANT • ADD INDEX • SELECT ONLY NEED using “scrooge” plugin replace SELECT *
  52. 52. • Version Control Everything
  53. 53. • Version Control Everything • Git cheap branches bring cheap feature
  54. 54. • Version Control Everything • Git • db migration version control db schema
  55. 55. • Version Control Everything • Git • db migration • package management config version control package dependency
  56. 56. GemfileAvailable since 2.3.x +
  57. 57. • Version Control Everything • Git • db migration • package management config • deployment using Capistrano to rollback back each build easily
  58. 58. • Automate Everything
  59. 59. • Automate Everything • template authentication, permission control, facebook integration, pagination,admin panel, seach engine,job worker,mailer....etc. rails blog -m ~/template.rb rails blog -m http://gist.github.com/31208.txt rake rails:template LOCATION=~/template.rb
  60. 60. • Automate Everything • template • deployment * memcached, search engine, mailer, job worker, db migrate....etc. * 1 machine, 2+ machines, 10+ machines .... * Capistrano auto deployment + Deploy VMs....
  61. 61. • Code Readability • OOP / Design Pattern • MVC • Rails Best Practice http://bit.ly/fIX3NV • Writing Efficiently Ruby Code http://bit.ly/e0PpPF • Writing team own best practices http://bit.ly/fL6aGI
  62. 62. • Product Quality • refactor architecture • SEO tuning • UI tuning • Pageview tuning • Business tuning
  63. 63. • Modern Architecture • Arel • Rack • ActiveModel • Bundler
  64. 64. • Modern Architecture • Arel Relational Algebra for Ruby simplifies the generation complex of SQL queries adapts to various RDBMS systems
  65. 65. Rack Rack middleware http://bit.ly/aZiOIs• Modern Architecture • Rack
  66. 66. • Modern Architecture • ActiveModel Everybody loves ActiveRecord’s feature ActionPack helpers Module Naming, Conversion, AttributeMethods, Callback, Dirty, MassAssignment Security,Observing,Serialization,Translation
  67. 67. • Modern Architecture • Bundler 1 project have 10-20+ gem / plugins A require ‘Z’ v=0.2.1 B require ‘Z’ v=0.1.2 => conflict! some plugin only have trunk version, especially when we are in Rails 3.0.0 pre
  68. 68. GemfileAvailable since 2.3.x +
  69. 69. • Modern Architecture • Bundler Dependency Resolution Groups of Dependencies support git , branch , tag bundle lock
  70. 70. survey• Compass Ruby CSS , CSS module http://bit.ly/i2XLyZ• CoffeeScript Ruby JavaScript• TDD / BDD• plugin....
  71. 71. • Query Reviwer....etc
  72. 72. just follow Rails !!
  73. 73. •••
  74. 74. Projects• 2010/04 : T• 2010/05 : event• 2010/08 : Digiphoto event• 2010/09 : event• 2010/10 : event• 2010/11 : T• 2010/12 : Digiphoto event• 2011/03 : R3
  75. 75. Rails Developer
  76. 76. ? ...
  77. 77. Rails ? ...
  78. 78. Rapid Development with fun and money• Deliver• http://bit.ly/eYfdba• ( ) || ( / ) http://bit.ly/dPk7od••
  79. 79. Thanks for listening
  80. 80. http://bit.ly/hDiq72Burn Rate
  81. 81. http://bit.ly/2UivVg( Agricola ) Startup / Website
  82. 82. http://blog.xdite.net
  83. 83. Q&A

×