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

Conceptualizing Rails after Sinatra

Conceptualizing Rails after Sinatra

A talk I gave at the NYC on Rails meetup at the Flatiron School one week into Rails

A23e38c82372e915869b636c8c3b18b2?s=128

Ruthie Nachmany

July 25, 2013
Tweet

Other Decks in Programming

Transcript

  1. CONCEPTUALIZING RAILS AFTER SINATRA My first week on Rails

  2. Rails vs. Sinatra •  “Rails is a framework focused on

    writing model driven web applications” •  “Sinatra is a library for dealing with HTTP from the server side” -Konstantin Haase, maintainer of Sinatra
  3. Sinatra as a Tool for Beginners •  Introduction to Rack/Middleware

    •  Opens up the world of Model-View-Controller (MVC) •  Write out RESTful routes •  Great error messages •  Beginning Ruby developers can begin to interact with their code on a new level
  4. How Sinatra Works •  One controller, many models, many views,

    •  Tightly linked MVC •  Controller-driven (for a beginner) •  Integrated with Active Record
  5. CHALLENGES IN CONCEPTUALIZING RAILS MVC RELATIONSHIPS

  6. Resources “A resource is the term used for a collection

    of similar objects” – Rails Guides
  7. Conceptualizing Rails After Sinatra •  Think in terms of dynamically-composed

    resources •  Object-oriented thinking on every level •  Model-driven
  8. RAILS AND SINATRA SOLVE DIFFERENT PROBLEMS

  9. Structural Differences •  Sinatra is not “pre” rails, but rather

    a different kind of thing •  Model-driven applications (Rails) •  Controller-driven applications (Sinatra) •  Sinatra deals with server-side HTTP requests
  10. Mix + Match •  Padrino (Ruby framework built on Sinatra)

    •  Yehuda Katz built Sinatra in Rails (testing whether Rails is a good toolkit for building new frameworks) •  Complementary frameworks: using Sinatra in Rails as tenant structures to modularize your app
  11. Convention vs Configuration “The biggest disadvantage with Sinatra not solving

    the issue for you is, well, Sinatra not solving the issue for you. You actually have to deal with that issue. You might end up wasting too much time dealing with it.” -Konstantin Haase “The default Rails app provides a lot that I need which requires extra setup in Sinatra. This can lead to faster development in Rails.” -Ryan Bates, Railscasts
  12. Framework vs Library •  “Inversion of Control is a key

    part of what makes a framework different to a library.” •  “A library is essentially a set of functions that you can call” •  “A framework embodies some abstract design, with more behavior built in. In order to use it you need to insert your behavior into various places in the framework either by subclassing or by plugging in your own classes” -Martin Fowler
  13. Takeaways •  Important to recognize the ways you are conceptualizing

    a new concept and what drives that •  When in doubt, return to objects •  Using the right tool for the right problem •  Tech talks for beginners = a great way to better understand what you’re confused about + open source the learning process