Ruby On Rails Presentation


Published on

Ruby on Rails intro by David Quitoriano

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Ruby On Rails Presentation

    1. 1. Ruby on Rails Optimized for programmer happiness and sustainable productivity Based on Curt Hibbs' Rails presentation to the St. Louis Java Users Group (June 2006)
    2. 2. Overview <ul><li>What is Ruby? </li></ul><ul><li>What is Rails? </li></ul><ul><li>MVC (Model-View-Controller) </li></ul><ul><li>Live Demonstration (sort of…) </li></ul><ul><li>Agile vs. Waterfall Model </li></ul><ul><li>Rails Applications in Production </li></ul><ul><li>Q&A </li></ul><ul><li>Resources </li></ul>
    3. 3. What is Ruby? <ul><li>A dynamic, object-oriented programming language with: </li></ul><ul><li>a strong focus on simplicity and productivity </li></ul><ul><li>Smalltalk's conceptual elegance, </li></ul><ul><li>Python's ease of use and learning, and </li></ul><ul><li>Perl's pragmatism. </li></ul><ul><li>Ruby originated in Japan during the mid-1990s and was initially developed and designed by Yukihiro &quot;Matz&quot; Matsumoto. </li></ul>
    4. 4. Ruby is... <ul><ul><li>Interpreted </li></ul></ul><ul><ul><ul><li>Like Perl, Python </li></ul></ul></ul><ul><ul><li>Object-Oriented </li></ul></ul><ul><ul><ul><li>Like Smalltalk, Eiffel, Ada, Java </li></ul></ul></ul><ul><ul><li>Rapidly Gaining Mindshare in US and Europe </li></ul></ul><ul><ul><ul><li>Originated in Japan, very popular there </li></ul></ul></ul>
    5. 5. Why Ruby? <ul><li>Easy to learn </li></ul><ul><li>Open source (very liberal license) </li></ul><ul><li>Rich libraries </li></ul><ul><li>Very easy to extend </li></ul><ul><li>Truly Object-Oriented </li></ul><ul><li>Excellent community </li></ul><ul><li>Bottom Line: write more understandable code in fewer lines </li></ul><ul><ul><li>Less code means fewer bugs </li></ul></ul>
    6. 6. Sample Ruby Code Code courtesy of John W. Long
    7. 7. Sample Ruby Code Code courtesy of John W. Long
    8. 8. What is Rails? <ul><li>“ Rails is a full-stack framework for developing database-backed web applications according to the Model-View-Control pattern.” </li></ul><ul><li> - Ruby on Rails official site </li></ul>
    9. 9. Rails is a Full-Stack Framework <ul><li>Includes everything needed to create a database-driven web application using the Model-View-Controller pattern. </li></ul><ul><li>Being a full-stack framework means that all layers are built to work seamlessly together. </li></ul><ul><li>That way you Don’t Repeat Yourself (DRY). </li></ul>
    10. 10. Rails is Agile <ul><li>built-in webserver </li></ul><ul><li>generators – save the fingers (CRUD) </li></ul><ul><li>scaffold – kick-off start </li></ul><ul><li>plugins, libraries, tons of contributed code </li></ul><ul><li>native AJAX support </li></ul><ul><li>“ leaving you to fill in the applications logic” </li></ul>
    11. 11. DHH <ul><li>David Heinemeier Hansson (28) is a Danish programmer and the creator of the popular Ruby on Rails web development framework. He is also a partner at the web-based software development firm 37signals. </li></ul><ul><li>In 2005 he was recognized by Google and O'Reilly with the Hacker of the Year award for his creation of Ruby on Rails. </li></ul><ul><li>Last July 2006, Business 2.0 ranked him 34th among '50 people who matter now'. </li></ul><ul><li>Source: Wikipedia ( </li></ul>
    12. 12. Principles of Ruby <ul><li>Japanese Design Aesthetics Shine Through </li></ul><ul><li>Focus on human factors </li></ul><ul><li>Principle of Least Surprise </li></ul><ul><li>Principle of Succinctness </li></ul><ul><li>Relevant because these principles were followed closely by the designer of Rails, David H. Hansson </li></ul><ul><ul><li>Scandinavian Design Aesthetic </li></ul></ul>
    13. 13. Philosophies <ul><li>Less Code </li></ul><ul><ul><li>Requires fewer total lines of code than other frameworks spend setting up their XML configuration files. </li></ul></ul><ul><li>Convention over Configuration </li></ul><ul><ul><li>Rails shuns configuration files in favor of conventions, reflection and dynamic run-time extensions. </li></ul></ul><ul><li>Configure your application by making it </li></ul><ul><ul><li>Your code and database schema are the configuration! </li></ul></ul><ul><ul><li>No compilation phase </li></ul></ul><ul><ul><ul><li>Make a change, see it work. </li></ul></ul></ul>
    14. 14. Traditional Applications <ul><li>Browser directly accesses page. </li></ul><ul><ul><li>Does not centralize control </li></ul></ul><ul><ul><li>No content/style separation </li></ul></ul><ul><ul><li>Easy and fast to produce </li></ul></ul><ul><ul><li>Difficult to maintain </li></ul></ul>
    15. 15. MVC Applications <ul><li>Browser accesses a “controller” </li></ul><ul><ul><li>Centralizes control </li></ul></ul><ul><ul><li>Clean separation of content/style </li></ul></ul><ul><ul><li>More involved to produce </li></ul></ul><ul><ul><li>Easier to maintain and expand </li></ul></ul>
    16. 16. Design Pattern <ul><li>A pattern that has been developed to help programmers cope with common problems. </li></ul><ul><li>Blueprints on how to construct something. </li></ul>
    17. 17. Typical Bakery Interaction <ul><li>Request a tasty treat from the baker </li></ul>
    18. 18. Baker responds with your treat
    19. 19. Bakery Flow
    20. 20. MVC Diagram
    21. 21. All Together Now
    22. 22. Rails and MVC <ul><li>Model (ActiveRecord) </li></ul><ul><ul><li>Maintains the relationship between Object and Database </li></ul></ul><ul><ul><li>Handles validation, association, transations, and more… </li></ul></ul><ul><ul><li>Does not completely insulate the developer from SQL </li></ul></ul>
    23. 23. Rails and MVC <ul><li>View (ActionView) </li></ul><ul><ul><li>Script-based templating system (like JSP, ASP, PHP, etc.) </li></ul></ul><ul><ul><li>Tight controller integration </li></ul></ul><ul><ul><li>Reusable components </li></ul></ul><ul><ul><li>Integrated, easy to use Ajax support. </li></ul></ul>
    24. 24. Rails and MVC <ul><li>Controller (ActionController) </li></ul><ul><ul><li>Reflection ties actions to methods </li></ul></ul><ul><ul><li>Tight view integration </li></ul></ul><ul><ul><li>Filters, layouts, caching, sessions, etc. </li></ul></ul>
    25. 25. Rails Demonstration
    26. 26. Testing Rails <ul><li>Rails has great testing framework ‘baked in’ the framework </li></ul><ul><ul><li>Test stubs created when code is ‘generated’. </li></ul></ul><ul><li>Unit to test models. </li></ul><ul><ul><li>test/unit </li></ul></ul><ul><li>Functional to test views/controllers </li></ul><ul><ul><li>test/functional </li></ul></ul><ul><li>Fixtures </li></ul><ul><ul><li>Supply test data (yaml) </li></ul></ul>
    27. 27. Unit Testing <ul><li>Separate ‘test’ database is used. </li></ul><ul><li>Fixtures supply data </li></ul><ul><li>Variety of ‘assert’ statements. </li></ul>
    28. 28. Database Support <ul><li>Supported Databases </li></ul><ul><ul><li>MySQL </li></ul></ul><ul><ul><li>PostgreSQL </li></ul></ul><ul><ul><li>SQLite </li></ul></ul><ul><ul><li>SQL Server </li></ul></ul><ul><li>Coming Soon </li></ul><ul><ul><li>Oracle </li></ul></ul><ul><ul><li>DB2 </li></ul></ul><ul><ul><li>Firebird </li></ul></ul><ul><ul><li>more… </li></ul></ul>
    29. 29. Server Configurations <ul><ul><li>WEBrick </li></ul></ul><ul><ul><ul><li>Built-in to Rails </li></ul></ul></ul><ul><ul><ul><li>Good development environment </li></ul></ul></ul><ul><ul><li>Apache/CGI </li></ul></ul><ul><ul><ul><li>Easy to set up, but slow </li></ul></ul></ul><ul><ul><li>Apache/mod_ruby </li></ul></ul><ul><ul><ul><li>Ruby interpreter per Apache process </li></ul></ul></ul><ul><ul><li>Apache/mod_fastcgi </li></ul></ul><ul><ul><ul><li>Pool of Ruby processes </li></ul></ul></ul><ul><ul><li>Lighttpd </li></ul></ul><ul><ul><ul><li>Built-in fastcgi support </li></ul></ul></ul><ul><ul><ul><li>Small footprint, high performance </li></ul></ul></ul>
    30. 30. Waterfall Model
    31. 32. Agile Programming
    32. 34. Agile Manifesto <ul><li>We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value: </li></ul><ul><li>Individuals and interactions over processes and tools </li></ul><ul><li>Working software over comprehensive documentation </li></ul><ul><li>Customer collaboration over contract negotiation </li></ul><ul><li>Responding to change over following a plan </li></ul>
    33. 35. <ul><ul><li>Get something real up and running quickly </li></ul></ul><ul><ul><li>Running software is the best way to build momentum, rally your team, and flush out ideas that don't work. It should be your number one priority from day one. </li></ul></ul><ul><ul><li>It's ok to do less, skip details, and take shortcuts in your process if it'll lead to running software faster. Once you're there, you'll be rewarded with a significantly more accurate perspective on how to proceed. Stories, wireframes, even html mockups, are just approximations. Running software is real. </li></ul></ul><ul><ul><li>With real, running software everyone gets closer to true understanding and agreement. You avoid heated arguments over sketches and paragraphs that wind up turning out not to matter anyway. You realize that parts you thought were trivial are actually quite crucial. </li></ul></ul><ul><ul><li> (IM Students required reading) </li></ul></ul>
    34. 36. Development Metrics <ul><li>Basecamp </li></ul><ul><ul><li>Launched in early 2004 </li></ul></ul><ul><ul><ul><li>“ Tens of thousands of users across 50 countries” </li></ul></ul></ul><ul><ul><ul><li>2 man-months of programming by a single developer (the Rails author). </li></ul></ul></ul><ul><ul><ul><li>4,000 Lines of Code. </li></ul></ul></ul><ul><ul><li>Server details </li></ul></ul><ul><ul><ul><li>One dual 2.2GHz Xeon, 2G RAM. </li></ul></ul></ul>
    35. 37. Development Metrics <ul><li>Backpack </li></ul><ul><ul><li>Launched in May 2005 </li></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><ul><ul><li>Makes very heavy use of Rails’ built-in Ajax support for an extremely responsive user interface. </li></ul></ul></ul>
    36. 38. Development Metrics <ul><li>43 Things </li></ul><ul><li>“ With Ruby and Rails we went from nothing to a live site in about 3 months . Only one person in the company had any prior Ruby experience (me) and he spent half his time playing sysadmin. </li></ul><ul><li>“ In the 2.5 months since launch we’ve done major rewrites of two of our core codepaths, added 3 large features and have done exploratory programming in two other directions with only 5 developers . </li></ul><ul><li>“ Our codebase is hanging in at just under 7,000 lines of production Ruby…” </li></ul><ul><li>As of February, 2005: </li></ul><ul><ul><li>9,000 registered users </li></ul></ul><ul><ul><li>200,000 hits per day </li></ul></ul>
    37. 39. Development Metrics <ul><li> </li></ul><ul><ul><li>Launched in February 2005 </li></ul></ul><ul><ul><ul><li>An ecommerce site marketing pregnancy related products. </li></ul></ul></ul><ul><ul><ul><li>2 developers and one graphic designer. </li></ul></ul></ul><ul><ul><ul><li>2,400 Lines of Code. </li></ul></ul></ul><ul><ul><ul><li>5 man-months of development time. </li></ul></ul></ul>
    38. 40. Development Metrics <ul><li> </li></ul><ul><ul><li>Launched in February 2005 </li></ul></ul><ul><ul><ul><li>An ecommerce site marketing snowboards and related gear. </li></ul></ul></ul><ul><ul><ul><li>2 developers . </li></ul></ul></ul><ul><ul><ul><li>6,000 lines of code. </li></ul></ul></ul><ul><ul><ul><li>4 months of development time. </li></ul></ul></ul>
    39. 41. Development Metrics <ul><li>StoryCards </li></ul><ul><ul><li>Web app to support XP-style development by Jim Weirich </li></ul></ul><ul><ul><li>http:// onestepback .org:3030/ </li></ul></ul><ul><ul><li>1,250 Lines of code </li></ul></ul><ul><ul><li>8 hours of development time </li></ul></ul>
    40. 42. Rails Testimonials <ul><ul><li>“ Rails is the most well thought-out web development framework I've ever used. And that's in a decade of doing web applications for a living. I've built my own frameworks, helped develop the Servlet API, and have created more than a few web servers from scratch. Nobody has done it like this before. That's not to say they got it all right. It's by no means &quot;perfect&quot;. I've got more than a few nits and picks about how things are put together. But &quot;perfect&quot; isn't the point. The point is that it gets you up and going fast and has plenty of depth to keep you going. And Rails does that very well.” </li></ul></ul><ul><ul><li>- James Duncan Davidson was the creator of Apache Tomcat and Apache Ant and was instrumental in their donation to the Apache Software Foundation by Sun Microsystems . While working at Sun, he authored two versions of the Java Servlet API specification as well as the Java API for XML Processing. </li></ul></ul>
    41. 43. “ I can only show you the door. You're the one that has to walk through it.” - Morpheus, The Matrix, 1999
    42. 44. In closing <ul><li>It's not the language. It's the programming principle. Simply put, “It's not the HOW, it's the WHY.” </li></ul><ul><li>Commitment to open source technologies (Java/Ruby/Phython) </li></ul><ul><li>Encourage a “Framework” mindset </li></ul><ul><li>Emphasis on application testing </li></ul><ul><li>Creators vs Followers </li></ul><ul><li>Innovators vs the Wait-and-see </li></ul><ul><li>Bleeding edge vs software that suck </li></ul>
    43. 45. Resources <ul><li>Ruby </li></ul><ul><ul><li>Main Ruby Site </li></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><ul><li>One-Click Ruby Installer for Windows </li></ul></ul><ul><ul><ul><li>http:// rubyinstaller . rubyforge .org/ </li></ul></ul></ul><ul><ul><li>RubyForge – open source project repository </li></ul></ul><ul><ul><ul><li>http:// rubyforge .org/ </li></ul></ul></ul><ul><li>Rails </li></ul><ul><ul><li>Main Rails Site </li></ul></ul><ul><ul><ul><li>http://www. rubyonrails .org/ </li></ul></ul></ul><ul><ul><li>Rails Tutorial (2 part series) </li></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><ul><li>Agile Web Development with Rails (first Rails book) </li></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><ul><li>Ajax on Rails </li></ul></ul><ul><ul><ul><li>http://www. onlamp .com/ </li></ul></ul></ul>