Web Development using Ruby on Rails
Upcoming SlideShare
Loading in...5
×
 

Web Development using Ruby on Rails

on

  • 305 views

 

Statistics

Views

Total Views
305
Views on SlideShare
305
Embed Views
0

Actions

Likes
0
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Web Development using Ruby on Rails Web Development using Ruby on Rails Presentation Transcript

  • Creating & Maintain Web Applications Avi Kedar, 8-2013
  •  New web approach  Programmers sucks  ails on b (Dynamic, KISS)  Development booster Deploy booster Rails on Ruby Rails
  • Server Data Layer Presentation Logic
  • Server Data Layer Presentation Logic
  • Front End SPA MV* Responsive OpenId Routing Duplex
  • Front End Presentation Logic Data Server Logic + Data Server Logic + Data • Queue • Distributed Cache • CDN • Storage • Processing Cloud Services JSON REST JSON REST JSON REST
  • Front End Server Logic + Data Cloud Services • Stateless • Data oriented • Small functioning parts • Less scale-up • Easy to integrate • Fast implementation (80/20)
  • Technology helps creating good projects, it doesn’t lead. Test your code, use patterns, avoid stickiness, use third-parties
  • • Launched in 2005 • Combination of Perl, Smalltalk and Lisp • Created byYukihiro Matsumoto • Open Source Often people, especially computer engineers, focus on the machines. They think, "By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, the machine will something something something." They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves. “ Yukihiro Matsumoto
  • • Executes on runtime • “Free hand”, no type restrictions • Strong reflection abilities • Metaprogramming Dynamic No pre-compile, no build, truly open for extensions
  • • Executes on runtime • “Free hand”, no type restrictions • Strong reflection abilities • Metaprogramming Dynamic a = [1, 'hi', 3.14, 1, 2, [4, 5]] hash = { water:'wet', fire:'hot' } l = lambda { "Do or do not" } class Time def yesterday self - 86400 end end module Debug def whoAmI? return "#{self.type.name} (##{self.id}): #{self.to_s}" end end class Toolbar include Debug # ... end
  • • Executes on runtime • “Free hand”, no type restrictions • Strong reflection abilities • Metaprogramming Dynamic 1.methods [:to_s, :-@, :+, :-, :*, :/, :div, :%, :modulo, ...] obj.respond_to?(:each) obj.is_a?(FixNum) obj.instance_of?(i) obj.nil? "hello".class "hello".variables
  • • Executes on runtime • “Free hand”, no type restrictions • Strong reflection abilities • Metaprogramming Dynamic obj.send :say_hello, 'Matz' define_method :hello do |my_arg| … end obj.instance_variable_set(:@x,10)
  • • Executes on runtime • “Free hand”, no type restrictions • Strong reflection abilities • Metaprogramming Dynamic COLORS = { black: "000", green: "0f0", blue: "00f“, white: "fff" } class String COLORS.each do |color,code| define_method "in_#{color}" do "<span style="color: ##{code}">#{self}</span>" end end end "Hello, World!".in_blue => "<span style="color: #00f">Hello, World!</span>"
  • • Convention, convention, convention • Write less • ?, !, @, @@, ||= • Read it KISS You don’t write code in Ruby You’re using Ruby style and practices to write better code … loops, blocks, dependencies, conditions, etc. …
  • • Convention, convention, convention • Write less • ?, !, @, @@, ||= • Read it KISS forget_about { } ( ) Always returns value Always receive block Person.new "Bob", 33 class Time def yesterday self - 86400 end end if number > 0 "#{number} is positive" else "#{number} is negative" end def demonstrate_block number yield number end puts demonstrate_block(1) do |number| number + 1 end
  • • Convention, convention, convention • Write less • ?, !, @, @@, ||= • Read it KISS person1.empty? person1.save! @first_name = “John” @@employees_count = 55 DEFAULT_LOCATION = “Israel” id ||= Guid.new
  • • Convention, convention, convention • Write less • ?, !, @, @@, ||= • Read it KISS (1..10).collect {|x| x*x} menu.delete_if {|key,value| value=='hot'} credit_card.pay! unless products.empty? 5.times { send_sms_to "xxx" }
  • • Launched in 2005 • Created by David Hansson • Open Source • Stack framework Test MVC Web Server Action Mailer Rake RESTfull ActiveRecord
  • • Convention, convention, convention • Reuse, collaboration • Test. Period. • Generators Dev Booster • IDE (simply console) • magic • wizards • config • attributes • dll’s • threads • IOC • unused files, code • MVC • REST • data layer • Easy to integrate • it looks stupid NO YES
  • • Convention, convention, convention • Reuse, collaboration • Test. Period. • Generators Dev Booster • IDE (simply console) • magic • wizards • config • attributes • dll’s • threads • IOC • unused files, code • MVC • REST • data layer • it looks stupid NO YES index.html.haml show.js.coffee
  • • Convention, convention, convention • Reuse, collaboration • Test. Period. • Generators Dev Booster Gem file You need an enormous reason to code something yourself. Easy to integrate Easy to use Fully documented Active community
  • • Convention, convention, convention • Reuse, collaboration • Test. Period. • Generators Dev Booster • Rspec for unit tests • Factory-girl for data generator • Capybara for integration test • Built in mocking system • Integrated with Rails, generators and build machines, huge amount of artifacts When “I sign in” do within "#login-form" do fill_in 'Login', with: 'user@example.com' fill_in 'Password', with: 'password' end click_link 'Sign in' end Capybara Rspec Team- city Factory- girl Fantom Browser RailsMocking& Generators JS, CSS, HTML, Ruby…
  • • Convention, convention, convention • Reuse, collaboration • Test. Period. • Generators Dev Booster • rails g controller Tweets • rails g controller Tags report_tag like_tag • rails g model Presentations title:string slides_count:integer • rails g rspec:controller Products • rails g scaffold OnlineGames game:string score:integer g
  • • Full responsibility o DB o Gems o Assets o Vendors • Multi-environment • Fast deploy Deploy Booster Rails Application
  • • Full responsibility o DB o Gems o Assets o Vendors • Multi-environment • Fast Setup • Fast deploy Deploy Booster • built in relational ORM • Part of the MVC (Model) • No SQL syntax, all using ActiveRecord built in functions (Ruby): ActiveRecord users = User.all Manage Databases • DB create/alter tables, indexes, etc. via ActiveRecord (Ruby): create_table :products do |t| t.string :name t.string :part_number end • Database structure and versioning using migrations 20111226120533_create_delayed_jobs.rb david = User.where(name:'David') david.age = 36 david.save!
  • • Full responsibility o DB o Gems o Assets o Vendors • Multi-environment • Fast Setup • Fast deploy Deploy Booster • Full versions and dependencies management • Group of gems per environment • Install and upgrade all using single command Gems bundle install bundle update gem 'SystemTimer', require: 'system_timer' gem 'feedback_popup' gem 'i18n-js' group :production do gem 'asset_sync' gem 'turbo-sprockets-rails3' gem 'coffee-rails' gem 'closure-compiler' gem 'yui-compressor' end
  • • Full responsibility o DB o Gems o Assets o Vendors • Multi-environment • Fast Setup • Fast deploy Deploy Booster • Single place to manage all your css, js, images and third- parties • Stack based manager called Assets Pipeline (easy to extend) (uglifier, unite to a single file, validate) • Control the order of bootstraping Assets Vendors • Manage all third-parties client side plugins (js and css) (jquery, angular-js, twitter-bootstrap, etc.) • Fully integrated with the assets pipeline
  • • Full responsibility o DB o Gems o Assets o Vendors • Multi-environment • Fast Setup • Fast deploy Deploy Booster • Support multiple environment separation using yaml config • Built-in test, development and production environment • Full separation: DB, dependencies, testing, data-seed Multi -environment
  • • Full responsibility o DB o Gems o Assets o Vendors • Multi-environment • Fast Setup • Fast deploy Deploy Booster • As fast as 3 steps to create a full active machine Fast Setup git pull <branch> bundle rake db:migrate • Single Responsibilty: o DB using SQLite o Server built in o UT support built in • Can illustrate production using multi-env rails s –e production
  • • Full responsibility o DB o Gems o Assets o Vendors • Multi-environment • Fast Setup • Fast deploy Deploy Booster • Using git as source control and deploy tool • Using artifacts for measure and investigate your code (UT, code coverage, memory lakes, etc.) • Fully integrated with Saas hosting platforms: o deploy in one click o Deploy software not infrastructure Add-ons: db-backups, logs, ssl, etc. • Scale-out in not a forbidden word: o Build for the cloud, so easy to integrate: Queue, CDN, storage, etc. o Scale your project in a single click Fast Deploy Build. Deploy. Scale. git push production 2.4
  •  Client side manage the flow and contains all presentation logic and view  Web servers should be data-oriented focusing on easy of scaling out and delivery speed  Ruby designed for programmers not machine: helps creating beautiful code, self-explained and dynamic  Rails enable to quickly create web servers:  Convention  Reuse  Single responsibility  Quick setup and deploy  Built-in scale out
  • Avi Kedar, 8-2013