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

7 Years of Ruby & Rails With the Same Web Site

Kevin Griffin
September 19, 2014

7 Years of Ruby & Rails With the Same Web Site

Experiences and lessons from maintaining and forking one Rails codebase for seven years. Code changes and people change!

Kevin Griffin

September 19, 2014
Tweet

Other Decks in Technology

Transcript

  1. 7 YEARS OF RUBY & RAILS WITH THE SAME WEB

    SITE ZEV BLUT KEVIN GRIFFIN & RUBYKAIGI2014
  2. RUBYKAIGI2014 History of Cerego 2007 2008 2009 2011 2013 iknow.co.jp

    Ruby Kaigi! smart.fm iknow.jp Cerego English cerego.com
  3. RUBYKAIGI2014 3 Lessons Learned 1. Sharing code is hard 2.

    Custom solutions require effort 3. People change
  4. RUBYKAIGI2014 Submodule Challenges • Bundler doesn’t work well • Editors

    and tools can’t deal with submodules • Deployment and Jenkins builds are complex
  5. RUBYKAIGI2014 Failures with Forks • Features get out of sync

    • Rails upgrades are harder • Differing systems requirements for each • (Ruby versions, RubyGems, C-extensions)
  6. RUBYKAIGI2014 Successes with Forks • Starting a new site is

    fast • Known codebase (everyone knows how it works) • Room for divergent changes
  7. RUBYKAIGI2014 We Used Lots of Custom Code • Gem Management

    • Asset Management • Access Control • Serialization • Natural Language Parser • Mobile Push Notifications
  8. RUBYKAIGI2014 “WTF?” • “Why aren’t we using this common tool?”

    • Bundler • Rails Asset Pipeline • Jbuilder • CanCan • Rails Russian doll caching • etc…
  9. RUBYKAIGI2014 Too Many Patches • Not sure what is native

    Ruby/Rails versus custom • Difficult to maintain when upgrading Rails • But we keep it all in a specific directory •vendor/patches
  10. RUBYKAIGI2014 When to be custom? • Concepts that haven’t made

    their way into Rails • Owning the core code: performant and specific • Domain-specific code
  11. RUBYKAIGI2014 When to move on? • Things break, Rails and

    Ruby change • Too much code builds around private APIs • Authors leave the project
  12. RUBYKAIGI2014 Use Standard Tools • Helps people get up to

    speed faster • Better documentation • Can share experiences with the world
  13. RUBYKAIGI2014 Rails 2.x to 3.x { “SELECT `users`.* from `users`

    WHERE `users`.`id` = 42 LIMIT 1;” => {“id"=>42,“name”=>"Zev"} } User.find(42) #<User id: 42, name: “zev”>
  14. RUBYKAIGI2014 Rails 2.x to 3.x def close @target.close if @target.respond_to?(:close)

    ensure ActiveRecord::Base.connection.clear_query_cache
  15. RUBYKAIGI2014 What happens when people leave? • Knowledge gets lost

    • Tests lose meaning • Well-designed code goes bad
  16. RUBYKAIGI2014 Knowledge Gets Lost • Workarounds are lost • Data

    structure meaning is lost • Dead code piles up
  17. RUBYKAIGI2014 Tests Lose Meaning • Test helpers are forgotten •

    Tests check values, not intention • Fixtures rot
  18. RUBYKAIGI2014 Well-designed Code Goes Bad • Intention isn’t maintained •

    Lots of small hacks build up • Code duplication
  19. RUBYKAIGI2014 What Can We Do? • Delete dead code •

    Keep everything up-to-date • Bootstrap new developers
  20. RUBYKAIGI2014 Delete Dead Code • Reduces mental overhead • Speeds

    up tests • Makes upgrading easier • Don’t fear the code
  21. RUBYKAIGI2014 3 Lessons Learned 1. Sharing code is hard 2.

    Custom solutions require effort 3. People change