SlideShare a Scribd company logo
1 of 31
Download to read offline
When to use Ruby on Rails?

        Sytse Sijbrandij
       sytse@dosire.com
Contents
• Ruby
  – What is it?
  – Advantages
  – Disadvantages
• Rails
  – What is it?
  – Advantages
  – Disadvantages
• When to use it
• Reusable best practices
                               Ruby Beach, Washington, U.S.
                                      Kevin Mc Neal
What is Ruby?
• A scripting language more powerful than
  Perl and more object-oriented than Python.
• Invented in 1993 with inspiration from Perl,
  Phyton, Smalltalk, Eiffel, Ada, and Lisp.
• Designed for programmer productivity and
  joy instead of machine efficiency.
• Follows the principle of least surprise, the
  language should minimize confusion.
                                               Yukihiro 'Matz' Matsumoto
• It's easy to work with and to love Ruby.                Ruby's Architect
Ruby Advantages
    Elegant
•
    Powerful
•
    Readable
•
    Concise
•



                     Ruby and Diamond ring
                         R. M. Rayner
describe Bowling do
                               before(:each) do

     Ruby is                     @bowling = Bowling.new
                               end


     Elegant                   it quot;should score 0 for gutter gamequot; do
                                 20.times { @bowling.hit(0) }
                                 @bowling.score.should == 0
                               end
                             end

class NewBowlingGame extends PHPSpec_Context
{
    private $_bowling = null;
    public function before()
    {
        $this->_bowling = new Bowling;
    }

    public function itShouldScore0ForGutterGame()
    {
        for ($i=1; $i<=20; $i++) {
            $this->_bowling->hit(0);
        }   $this->spec($this->_bowling->score)->should->equal(0);
    }
}
Ruby is Powerful
  • Object-oriented (everything is an object)
  • Dynamic (duck typing)
# Open Ruby's Time class and add a method
class Time
  def yesterday
    self - 86400
  end
end

today = Time.now # => Thu Aug 14 16:51:50 +1200 2008
yesterday = today.yesterday # => Wed Aug 13 16:51:50 +1200 2008
Ruby is Readable
• The code comments itself
• Leads to better naming practices
# An example example function for a photo camera program
def shutter_clicked
  capture_image if @camera.on? and @camera.memory_available?
end
Ruby is Concise
• Very expressive language
• Less lines of code, higher productivity
-199.abs                                              # 199
quot;ruby is coolquot;.length                                 # 12
quot;Your Momquot;.index(quot;uquot;)                                 #2
quot;Nice Day!quot;.downcase.split(//).sort.uniq.join # quot; !acdeinyquot;

say = quot;I love Rubyquot;
say['love'] = quot;*love*quot;
5.times { puts say }
=> quot;I *love* Rubyquot; quot;I *love* Rubyquot; quot;I *love* Rubyquot; quot;I
*love* Rubyquot; quot;I *love* Rubyquot;
Ruby Disadvantages
• Ruby is Slow
• Ruby is New




                  Ruby Fails Falls, Lookout Mountain, U.S.
                                   Oscar & L
Ruby is Slow
• About 10x slower than Java, 2x slower than PHP




               All benchmarks, x64 Ubuntu, Intel Q6600 Quad
                   Computer Language Benchmarks Game
Ruby is New
• Not many developers or customers
• No common IDE
  – Most coders use the Mac text-editor Textmate
  – IDEs: RadRails, RubyMine, 3rd Rail, Netbeans
• No common application server
  – Passenger's Apache module has momentum
Evolution to web frameworks
                                  From 1990 to 2009
Time


                   Static          Dynamic                Integrated
Type of site

                Marketing       Front office          Back office
Business role
                • Brochure      • Communication       • Quotations
                • Advertising   • Ordering            • Fulfillment
                                • Mailings            • Legacy systems
Tools           HTML editors:   PHP + MySQL:          Frameworks:
                Frontpage       Joomla                CakePHP (PHP)
                Dreamweaver     Drupal                Grails (Groovy)
                                Wordpress             Django (Phyton)
                                Typo3                 Ruby on Rails (Ruby)
                                                      Merb (Ruby)
                                .Net                  Sanatra (Ruby)
                                Sharepoint
What is             ?
                                         Creator of Ruby on Rails
• Web application framework            David Heinemeier Hansson

• Open Source (MIT license)
• Based on a existing
  application (Basecamp)
• Provides common needs:
      Routing, sessions
  –
      Database storage
  –
      Business logic
  –
      Generate HTML/XML/CSS/Ajax
  –
      Testing
  –
Who uses Rails
    Internally:
•
    Externally:
•
    style.mtv.com
•
    www.getsatisfaction.com
•
    www.basecamp.com
•
    www.yellowpages.com
•
    www.twitter.com
•
    www.yelloyello.nl
•
Rails Advantages
    Convention over configuration
•
    Don’t Repeat Yourself
•
    Object Relational Mapping
•
    Model View Controller
•                                   Tay Rail Bridge, Scotland
                                                   Ross2085

    Reuse of code
•
    Agile practices
•
    Security
•
Convention over Configuration
• Table and foreign key naming
  – Tables are multiples
    (users, orders, etc.)
  – Foreign key naming: user_id
• Default locations
  – MVC, Tests, Languages, Plugins
• Naming
  – Class names: CamelCase
  – Files: lowercase_underscored.rb
Don’t repeat yourself
• Everything is defined in a single,
  unambiguous place
• Easier to find code
  – Only need to look once
  – Can stop looking when found
  – Well defined places for most items
• Much easier to maintain code
  – Faster to change
  – Less inconsistency bugs
Model View Controller
• Model
  – Object relationships
    (users, orders)
• Controller
  – Business logic
    (perform a payment)
• View
  – Visual representation
    (generate HTML/XML)
Model
• Contains validation and object methods
• Use 'fat' models and 'skinny' controllers to
  increase reuse of methods across controllers
        class Order < ActiveRecord::Base
           has_many :line_items
           has_one :user
           has_one :email, :through => :user

              validates_presence_of :user
              validates_numericality_of :amount

              def purchase
                  self.purchase_time = Now
              end
        end
View
• DSL languages              #content
                               .left.column
      Erb for ruby & html
  •                              %h2 Welcome to our site!
                                 %p= print_information
      Haml improves on erb
  •                            .right.column= render quot;sidebarquot;
      Textile for html
  •
      Sass for css
  •
                       <div id='content'>
                         <div class='left column'>
                           <h2>Welcome to our site!</h2>
                           <p>
                             <%= print_information %>
                           </p>
                         </div>
                         <div class=quot;right columnquot;>
                           <%= render quot;sidebarquot; %>
                         </div>
                       </div>
Controller
                         Method      Resource     Verb
• RESTful                index       /people      GET
                         show        /people/12   GET
  – Better than SOAP     create      /people      POST
  – Easy to understand   update      /people/12   PUT
                         delete      /people/12   DELETE
  – Easy to debug
                         GET /people/12.xml
  – Easy to cache
                         def show
  – Easy to prioritize      @person =
                                Person.find(params[:id])
  – No bottleneck           respond_to do |wants|
  – HTML/XML/JSON                wants.html
                                 wants.xml { render :xml
                         => @person.to_xml }
                            end
                         end
Object Relational Mapping
                                     find
Programming object                               Database row

                                 ORM Tools:
#<User id: 1, login: quot;Sytsequot;,    -ActiveRecord
email: quot;sytse@comcoaster.comquot;,
                                 -DataMapper
description: quot;<p>Sytse studied
                                 -iBATIS
Management Science at the
Universi...quot;, avatar_id: 1,
crypted_password:
quot;b6675cab85b541a91e6d0
                                      save

            # Examples of finding records
            User.find(:all)
            User.find(23).articles
            User.find_by_first_name('Johnny')
            User.order.find(:last).lines_items.count
Re-use of code
• Gems and plugins, more then 1300
  – For authentication, pagination, testing, etc.
• Git allows easy forking and merging
• Github website allows you to give back
• Acts as a portfolio
Agile practices
• Iterations (branch often, merge often)
• Test all the time (TDD, BDD)
  Stories > Tests > Code > Continuous Integration
     Story example
     Feature: Log-in
       In order to view my profile
       As a Registered member
       I want to be required to log-in

     Test example
     Given /I am the registered member quot;quirequot;/ do
       @user = User.new({ :login => 'quire})
       @user.save!
     end
Security
• Rails prevents SQL injection attacks
  – Attacher post in form: quot;some_title; DROP TABLE articles;quot;
  – In bad code this can be injected:
    quot;SELECT * FROM ARTICLES WHERE TITLE = $TITLEquot;
  – Rails will be escape the input automatically:
    @articles = Article.find(:all,
                    :conditions => [:title => params[:title]])
• Rails prevents Cross Site Scripting (XSS)
  – With html_escape in view: <%=h comment.body %>
Rails Disadvantages
• Rails is inefficient
• Rails is hard to deploy




                            Montparnesse 1895
                                  Jeff Mc Neill
Rails is inefficient
   • Rails uses a lot of memory,
     up to 150MB per instance
   • Requires more application servers
   • Where are your development constrains?
Resource           Example application            Rails
Man hours          2.200 hours / e22.000          1.000 hours / e10.000

Project duration   15 weeks of changes / e3.000   10 weeks / e2.000
Computing power    2 servers / e2.000             5 servers / e5.000
Total              e27.000                        e17.000
Rails is hard to deploy
• Harder than PHP, better with Passenger
• Lots of moving parts
  – Rails, apps, gems, plugins
  – Application server, webserver
• Deployment via scripts
  – Via the Capistrano tool
  – Easy to break something
• Deployment to multiple servers
When to use Ruby on Rails?
    New code base and DB            Existing code and DB
•                               •
    High development speed          Low development speed
•                               •
    Complex applications            Simple applications
•                               •
    Web deployment                  Client deployment
•                               •
    Iterative projects              Waterfall projects
•                               •
    Development is expensive        Deployment is expensive
•                               •
    Fixed price project             Hourly rate project
•                               •
    Early adopter client/team       Late majority client/team
•                               •
Re-usable best practices
• Don't Repeat Yourself
• 'Fat' model, 'skinny' controller
• MVC framework
   – CakePHP
• Integration testing
   – Selenium
• DSL's
   – Textile for markup
• Source code repository
   – GIT
• Project management                 Recycle shirt by Brian Damage
   – Github, Lighthouse, Basecamp
Questions?




http://www.dosire.com/

More Related Content

What's hot

Let's Learn Ruby - Basic
Let's Learn Ruby - BasicLet's Learn Ruby - Basic
Let's Learn Ruby - BasicEddie Kao
 
Web development using javaScript, React js, Node js, HTML, CSS and SQL
Web development using javaScript, React js, Node js, HTML, CSS and SQLWeb development using javaScript, React js, Node js, HTML, CSS and SQL
Web development using javaScript, React js, Node js, HTML, CSS and SQLJayant Surana
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScriptLilia Sfaxi
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javajayc8586
 
Introduction to Java
Introduction to Java Introduction to Java
Introduction to Java Hitesh-Java
 
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for BeginnersEdureka!
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump AnalysisDmitry Buzdin
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and StatementsWebStackAcademy
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 

What's hot (20)

Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Let's Learn Ruby - Basic
Let's Learn Ruby - BasicLet's Learn Ruby - Basic
Let's Learn Ruby - Basic
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Web development using javaScript, React js, Node js, HTML, CSS and SQL
Web development using javaScript, React js, Node js, HTML, CSS and SQLWeb development using javaScript, React js, Node js, HTML, CSS and SQL
Web development using javaScript, React js, Node js, HTML, CSS and SQL
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Pentesting ReST API
Pentesting ReST APIPentesting ReST API
Pentesting ReST API
 
Introduction to Java
Introduction to Java Introduction to Java
Introduction to Java
 
Java presentation
Java presentation Java presentation
Java presentation
 
php
phpphp
php
 
Web api
Web apiWeb api
Web api
 
Spring Batch 2.0
Spring Batch 2.0Spring Batch 2.0
Spring Batch 2.0
 
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for Beginners
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump Analysis
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
PHP - Web Development
PHP - Web DevelopmentPHP - Web Development
PHP - Web Development
 
Soap vs rest
Soap vs restSoap vs rest
Soap vs rest
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 

Viewers also liked

JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesTikal Knowledge
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Tom Brander
 
Programming for the non-programmer
Programming for the non-programmerProgramming for the non-programmer
Programming for the non-programmerStelian Firez
 
Le Wagon On Demand - Behind the scenes
Le Wagon On Demand - Behind the scenesLe Wagon On Demand - Behind the scenes
Le Wagon On Demand - Behind the scenesSébastien Saunier
 
Le Wagon - Technical entrepreneurship
Le Wagon - Technical entrepreneurshipLe Wagon - Technical entrepreneurship
Le Wagon - Technical entrepreneurshipBoris Paillard
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
Techical Workflow for a Startup
Techical Workflow for a StartupTechical Workflow for a Startup
Techical Workflow for a StartupSébastien Saunier
 
Le Wagon - UI components design
Le Wagon - UI components designLe Wagon - UI components design
Le Wagon - UI components designBoris Paillard
 
Le Wagon - Bootcamp in Ruby on Rails, HTML, CSS and JavaScript
Le Wagon - Bootcamp in Ruby on Rails, HTML, CSS and JavaScriptLe Wagon - Bootcamp in Ruby on Rails, HTML, CSS and JavaScript
Le Wagon - Bootcamp in Ruby on Rails, HTML, CSS and JavaScriptBoris Paillard
 
Le Wagon's Product Design Sprint
Le Wagon's Product Design SprintLe Wagon's Product Design Sprint
Le Wagon's Product Design SprintBoris Paillard
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby BasicsSHC
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails PresentationJoost Hietbrink
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Coursepeter_marklund
 

Viewers also liked (20)

Ruby on Rails for beginners
Ruby on Rails for beginnersRuby on Rails for beginners
Ruby on Rails for beginners
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?
 
Programming for the non-programmer
Programming for the non-programmerProgramming for the non-programmer
Programming for the non-programmer
 
PHP vs. Ruby on Rails
PHP vs. Ruby on RailsPHP vs. Ruby on Rails
PHP vs. Ruby on Rails
 
Le Wagon On Demand - Behind the scenes
Le Wagon On Demand - Behind the scenesLe Wagon On Demand - Behind the scenes
Le Wagon On Demand - Behind the scenes
 
How Le Wagon uses Trello
How Le Wagon uses TrelloHow Le Wagon uses Trello
How Le Wagon uses Trello
 
Perl Introduction
Perl IntroductionPerl Introduction
Perl Introduction
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Le Wagon - Technical entrepreneurship
Le Wagon - Technical entrepreneurshipLe Wagon - Technical entrepreneurship
Le Wagon - Technical entrepreneurship
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
Techical Workflow for a Startup
Techical Workflow for a StartupTechical Workflow for a Startup
Techical Workflow for a Startup
 
Le Wagon - UI components design
Le Wagon - UI components designLe Wagon - UI components design
Le Wagon - UI components design
 
Le Wagon - Bootcamp in Ruby on Rails, HTML, CSS and JavaScript
Le Wagon - Bootcamp in Ruby on Rails, HTML, CSS and JavaScriptLe Wagon - Bootcamp in Ruby on Rails, HTML, CSS and JavaScript
Le Wagon - Bootcamp in Ruby on Rails, HTML, CSS and JavaScript
 
Le Wagon's Product Design Sprint
Le Wagon's Product Design SprintLe Wagon's Product Design Sprint
Le Wagon's Product Design Sprint
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 

Similar to When To Use Ruby On Rails

Framework Presentation
Framework PresentationFramework Presentation
Framework Presentationrmalik2
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingBozhidar Batsov
 
Ruby on Rails in UbiSunrise
Ruby on Rails in UbiSunriseRuby on Rails in UbiSunrise
Ruby on Rails in UbiSunriseWisely chen
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworksguestf7bc30
 
Introduction To Ruby On Rails
Introduction To Ruby On RailsIntroduction To Ruby On Rails
Introduction To Ruby On RailsSteve Keener
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracketjnewmanux
 
Haml And Sass
Haml And SassHaml And Sass
Haml And Sasswear
 
Intro To Django
Intro To DjangoIntro To Django
Intro To DjangoUdi Bauman
 
Web Development: The Next Five Years
Web Development: The Next Five YearsWeb Development: The Next Five Years
Web Development: The Next Five Yearssneeu
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceJesse Vincent
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2rubyMarc Chung
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHPRob Knight
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteDr Nic Williams
 
Optimizing AngularJS Application
Optimizing AngularJS ApplicationOptimizing AngularJS Application
Optimizing AngularJS ApplicationMd. Ziaul Haq
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous MerbMatt Todd
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsMike Subelsky
 

Similar to When To Use Ruby On Rails (20)

Framework Presentation
Framework PresentationFramework Presentation
Framework Presentation
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programing
 
Practical Groovy DSL
Practical Groovy DSLPractical Groovy DSL
Practical Groovy DSL
 
Ruby on Rails in UbiSunrise
Ruby on Rails in UbiSunriseRuby on Rails in UbiSunrise
Ruby on Rails in UbiSunrise
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
 
Api Design
Api DesignApi Design
Api Design
 
Introduction To Ruby On Rails
Introduction To Ruby On RailsIntroduction To Ruby On Rails
Introduction To Ruby On Rails
 
Happy Coding with Ruby on Rails
Happy Coding with Ruby on RailsHappy Coding with Ruby on Rails
Happy Coding with Ruby on Rails
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracket
 
Haml And Sass
Haml And SassHaml And Sass
Haml And Sass
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
 
Web Development: The Next Five Years
Web Development: The Next Five YearsWeb Development: The Next Five Years
Web Development: The Next Five Years
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
Optimizing AngularJS Application
Optimizing AngularJS ApplicationOptimizing AngularJS Application
Optimizing AngularJS Application
 
Road to Rails
Road to RailsRoad to Rails
Road to Rails
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

When To Use Ruby On Rails

  • 1. When to use Ruby on Rails? Sytse Sijbrandij sytse@dosire.com
  • 2. Contents • Ruby – What is it? – Advantages – Disadvantages • Rails – What is it? – Advantages – Disadvantages • When to use it • Reusable best practices Ruby Beach, Washington, U.S. Kevin Mc Neal
  • 3. What is Ruby? • A scripting language more powerful than Perl and more object-oriented than Python. • Invented in 1993 with inspiration from Perl, Phyton, Smalltalk, Eiffel, Ada, and Lisp. • Designed for programmer productivity and joy instead of machine efficiency. • Follows the principle of least surprise, the language should minimize confusion. Yukihiro 'Matz' Matsumoto • It's easy to work with and to love Ruby. Ruby's Architect
  • 4. Ruby Advantages Elegant • Powerful • Readable • Concise • Ruby and Diamond ring R. M. Rayner
  • 5. describe Bowling do before(:each) do Ruby is @bowling = Bowling.new end Elegant it quot;should score 0 for gutter gamequot; do 20.times { @bowling.hit(0) } @bowling.score.should == 0 end end class NewBowlingGame extends PHPSpec_Context { private $_bowling = null; public function before() { $this->_bowling = new Bowling; } public function itShouldScore0ForGutterGame() { for ($i=1; $i<=20; $i++) { $this->_bowling->hit(0); } $this->spec($this->_bowling->score)->should->equal(0); } }
  • 6. Ruby is Powerful • Object-oriented (everything is an object) • Dynamic (duck typing) # Open Ruby's Time class and add a method class Time def yesterday self - 86400 end end today = Time.now # => Thu Aug 14 16:51:50 +1200 2008 yesterday = today.yesterday # => Wed Aug 13 16:51:50 +1200 2008
  • 7. Ruby is Readable • The code comments itself • Leads to better naming practices # An example example function for a photo camera program def shutter_clicked capture_image if @camera.on? and @camera.memory_available? end
  • 8. Ruby is Concise • Very expressive language • Less lines of code, higher productivity -199.abs # 199 quot;ruby is coolquot;.length # 12 quot;Your Momquot;.index(quot;uquot;) #2 quot;Nice Day!quot;.downcase.split(//).sort.uniq.join # quot; !acdeinyquot; say = quot;I love Rubyquot; say['love'] = quot;*love*quot; 5.times { puts say } => quot;I *love* Rubyquot; quot;I *love* Rubyquot; quot;I *love* Rubyquot; quot;I *love* Rubyquot; quot;I *love* Rubyquot;
  • 9. Ruby Disadvantages • Ruby is Slow • Ruby is New Ruby Fails Falls, Lookout Mountain, U.S. Oscar & L
  • 10. Ruby is Slow • About 10x slower than Java, 2x slower than PHP All benchmarks, x64 Ubuntu, Intel Q6600 Quad Computer Language Benchmarks Game
  • 11. Ruby is New • Not many developers or customers • No common IDE – Most coders use the Mac text-editor Textmate – IDEs: RadRails, RubyMine, 3rd Rail, Netbeans • No common application server – Passenger's Apache module has momentum
  • 12. Evolution to web frameworks From 1990 to 2009 Time Static Dynamic Integrated Type of site Marketing Front office Back office Business role • Brochure • Communication • Quotations • Advertising • Ordering • Fulfillment • Mailings • Legacy systems Tools HTML editors: PHP + MySQL: Frameworks: Frontpage Joomla CakePHP (PHP) Dreamweaver Drupal Grails (Groovy) Wordpress Django (Phyton) Typo3 Ruby on Rails (Ruby) Merb (Ruby) .Net Sanatra (Ruby) Sharepoint
  • 13. What is ? Creator of Ruby on Rails • Web application framework David Heinemeier Hansson • Open Source (MIT license) • Based on a existing application (Basecamp) • Provides common needs: Routing, sessions – Database storage – Business logic – Generate HTML/XML/CSS/Ajax – Testing –
  • 14. Who uses Rails Internally: • Externally: • style.mtv.com • www.getsatisfaction.com • www.basecamp.com • www.yellowpages.com • www.twitter.com • www.yelloyello.nl •
  • 15. Rails Advantages Convention over configuration • Don’t Repeat Yourself • Object Relational Mapping • Model View Controller • Tay Rail Bridge, Scotland Ross2085 Reuse of code • Agile practices • Security •
  • 16. Convention over Configuration • Table and foreign key naming – Tables are multiples (users, orders, etc.) – Foreign key naming: user_id • Default locations – MVC, Tests, Languages, Plugins • Naming – Class names: CamelCase – Files: lowercase_underscored.rb
  • 17. Don’t repeat yourself • Everything is defined in a single, unambiguous place • Easier to find code – Only need to look once – Can stop looking when found – Well defined places for most items • Much easier to maintain code – Faster to change – Less inconsistency bugs
  • 18. Model View Controller • Model – Object relationships (users, orders) • Controller – Business logic (perform a payment) • View – Visual representation (generate HTML/XML)
  • 19. Model • Contains validation and object methods • Use 'fat' models and 'skinny' controllers to increase reuse of methods across controllers class Order < ActiveRecord::Base has_many :line_items has_one :user has_one :email, :through => :user validates_presence_of :user validates_numericality_of :amount def purchase self.purchase_time = Now end end
  • 20. View • DSL languages #content .left.column Erb for ruby & html • %h2 Welcome to our site! %p= print_information Haml improves on erb • .right.column= render quot;sidebarquot; Textile for html • Sass for css • <div id='content'> <div class='left column'> <h2>Welcome to our site!</h2> <p> <%= print_information %> </p> </div> <div class=quot;right columnquot;> <%= render quot;sidebarquot; %> </div> </div>
  • 21. Controller Method Resource Verb • RESTful index /people GET show /people/12 GET – Better than SOAP create /people POST – Easy to understand update /people/12 PUT delete /people/12 DELETE – Easy to debug GET /people/12.xml – Easy to cache def show – Easy to prioritize @person = Person.find(params[:id]) – No bottleneck respond_to do |wants| – HTML/XML/JSON wants.html wants.xml { render :xml => @person.to_xml } end end
  • 22. Object Relational Mapping find Programming object Database row ORM Tools: #<User id: 1, login: quot;Sytsequot;, -ActiveRecord email: quot;sytse@comcoaster.comquot;, -DataMapper description: quot;<p>Sytse studied -iBATIS Management Science at the Universi...quot;, avatar_id: 1, crypted_password: quot;b6675cab85b541a91e6d0 save # Examples of finding records User.find(:all) User.find(23).articles User.find_by_first_name('Johnny') User.order.find(:last).lines_items.count
  • 23. Re-use of code • Gems and plugins, more then 1300 – For authentication, pagination, testing, etc. • Git allows easy forking and merging • Github website allows you to give back • Acts as a portfolio
  • 24. Agile practices • Iterations (branch often, merge often) • Test all the time (TDD, BDD) Stories > Tests > Code > Continuous Integration Story example Feature: Log-in In order to view my profile As a Registered member I want to be required to log-in Test example Given /I am the registered member quot;quirequot;/ do @user = User.new({ :login => 'quire}) @user.save! end
  • 25. Security • Rails prevents SQL injection attacks – Attacher post in form: quot;some_title; DROP TABLE articles;quot; – In bad code this can be injected: quot;SELECT * FROM ARTICLES WHERE TITLE = $TITLEquot; – Rails will be escape the input automatically: @articles = Article.find(:all, :conditions => [:title => params[:title]]) • Rails prevents Cross Site Scripting (XSS) – With html_escape in view: <%=h comment.body %>
  • 26. Rails Disadvantages • Rails is inefficient • Rails is hard to deploy Montparnesse 1895 Jeff Mc Neill
  • 27. Rails is inefficient • Rails uses a lot of memory, up to 150MB per instance • Requires more application servers • Where are your development constrains? Resource Example application Rails Man hours 2.200 hours / e22.000 1.000 hours / e10.000 Project duration 15 weeks of changes / e3.000 10 weeks / e2.000 Computing power 2 servers / e2.000 5 servers / e5.000 Total e27.000 e17.000
  • 28. Rails is hard to deploy • Harder than PHP, better with Passenger • Lots of moving parts – Rails, apps, gems, plugins – Application server, webserver • Deployment via scripts – Via the Capistrano tool – Easy to break something • Deployment to multiple servers
  • 29. When to use Ruby on Rails? New code base and DB Existing code and DB • • High development speed Low development speed • • Complex applications Simple applications • • Web deployment Client deployment • • Iterative projects Waterfall projects • • Development is expensive Deployment is expensive • • Fixed price project Hourly rate project • • Early adopter client/team Late majority client/team • •
  • 30. Re-usable best practices • Don't Repeat Yourself • 'Fat' model, 'skinny' controller • MVC framework – CakePHP • Integration testing – Selenium • DSL's – Textile for markup • Source code repository – GIT • Project management Recycle shirt by Brian Damage – Github, Lighthouse, Basecamp