This document discusses technologies for creating and maintaining web applications. It covers Ruby and the Rails framework. Ruby is designed to be programmer-focused rather than machine-focused, helping create dynamic and self-explained code. Rails enables quickly building web servers through conventions, reuse, single responsibility principles, and features that provide quick setup, deployment, and built-in scalability. The document also discusses front-end architecture with client-side logic, and Rails features for development, deployment, databases, assets, and multi-environment configuration.
7. Front End
Server
Logic + Data
Cloud
Services
• Stateless
• Data oriented
• Small functioning parts
• Less scale-up
• Easy to integrate
• Fast implementation
(80/20)
8. Technology helps creating good projects, it doesn’t lead.
Test your code, use patterns, avoid stickiness, use third-parties
9. • 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
10. • Executes on runtime
• “Free hand”, no type restrictions
• Strong reflection abilities
• Metaprogramming
Dynamic
No pre-compile, no build, truly open for extensions
11. • 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
13. • 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)
14. • 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>"
15. • 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. …
16. • 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
17. • Convention, convention, convention
• Write less
• ?, !, @, @@, ||=
• Read it
KISS person1.empty?
person1.save!
@first_name = “John”
@@employees_count = 55
DEFAULT_LOCATION = “Israel”
id ||= Guid.new
19. • Launched in 2005
• Created by David Hansson
• Open Source
• Stack framework
Test
MVC
Web Server
Action
Mailer
Rake
RESTfull ActiveRecord
20. • 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
21. • 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
22. • 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
23. • 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…
24. • 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
25. • Full responsibility
o DB
o Gems
o Assets
o Vendors
• Multi-environment
• Fast deploy
Deploy Booster
Rails Application
26. • 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!
27. • 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
28. • 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
29. • 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
30. • 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
31. • 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
32. 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