PowerPoint File - ACS (Australian Computer Society) - Membership ...
-
Upload
sampetruda -
Category
Documents
-
view
2.098 -
download
1
Transcript of PowerPoint File - ACS (Australian Computer Society) - Membership ...
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Why does RoR interest us?
• Learn “new” concepts and terms.• Look at “new” architecture.• Find out what is good and what is dubious.• May well come across RoR or a Rails-like framework
in near future.• May want to learn an object-oriented language
relatively painlessly.• RoR is easy to install, learn and use. You might want
to try it out for yourself!
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Executive Summary• A lot of hype (many evangelists)• Some dubious claims• Some very good, new concepts• Some old concepts with new names• Ruby camp - humble• Rails camp - arrogant• Still missing some essential tools• Rails techniques can certainly be applied elsewhere• Surprisingly large tools and software base• But Ruby and Rails are each very powerful in their own right
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
At First Sight• Can only be used for web-based, specifically HTML-
based, applications• Designed for small to medium CRUD-based
applications• Cross-platform• Can use same tools and middleware on Windows,
Linux and OS X.• Easy-install packages for Eclipse (with RADRails and
Ruby editor plugins), MySQL, Apache, and other Eclipse plugins, eg Subversion.
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Books• Beyond Java - Bruce Tate (evangelist)
• Programming Ruby (The Pragmatic Programmers’ Guide) - Dave Thomas
• Ruby Cookbook - Carlson & RichardsonAgile Web Development with Rails (Pragmatic
Programmers) - Thomas, Hansson, Breedt and Clark
• Rails Recipes - Chad FowlerRuby on Rails (Up and Running) - Tate & Gibbs
[160 pages]
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Other References
• Ruby home pagehttp://www.ruby-lang.org/en/
• Ruby Centralhttp://www.rubycentral.com/
• Rails home pagehttp://www.rubyonrails.org/
• Wikipedia entries on Ruby and Ruby on Rails
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Available Information
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
History of Ruby• 1993, Feb 24: Yukihiro Matsumoto ("Matz")
started work on Ruby• 1993, Summer: First "Hello, world!" program• 1995, December: First release 0.95• 1996, December: 1.0 is released• 1999: Supposedly overtakes Python in Japan• 2000: The first official newsgroup• 2000-2001: Several books published• 2003, August 4: 1.8.0 is released
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
History of Rails
• Developed by David Heinemeier Hansson as part of an application called Basecamp.
• 2004, July: Released the framework as open source
• 2005, Feb: Shared the commit rights• 2005, Dec: Version 1.0 released• 2006, Mar: Version 1.1 released• 2007, Jan: Version 1.2 released
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
A Ruby Exampleclass Accountattr_reader :balance #accessorprotected :balancedef initialize(balance)
@balance = balanceenddef greater_balance_than(other)
return @balance > other.balanceend
end
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
A P
eak
at R
ails .
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Basics
• Ruby - fully object oriented
• Rails - full stack framework (sort of)
• ActionView, ActionController, ActiveRecord
• AJAX using script.aculo.us JavaScript libraries
• Uses rake (like make or Ant)
• Can use an interpreter to try out Ruby commands
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Rub
y on
Rai
lsR
eque
st F
low
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Terms and Concepts
• Duck Typing
• DRY (Don’t Repeat Yourself)
• MVC (Model-View-Controller)
• Model2 - stateless web apps
• Metaprogramming
• Convention Over Configuration
• Scaffolding
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Deployment Environments• Development, Test and Production• Each has its own, default runtime settings• One database for each• Schema Migrations
– Manages the schemas and any changes– Keeps track of a list of migrations– Each migration has version number– Can modify schema without losing data– Can migrate schema through test and production– Can make or undo the schema change
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Automated Testing• RoR generates default test cases to test each method
in each class• Uses assertions to test results against expected
values• Test data refreshed on start of test• Fixtures - contain your test data• Unit Tests - for testing models• Functional Tests - for testing controllers• Integration Tests - for higher level scenarios• Functional and Integration Tests check Http responses• ZenTest and Selenium
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Configuration• Uses Convention over Configuration, and Reflection• Therefore very little configuration compared to other
frameworks• ActiveRecord configuration can use SQL• Uses YAML (easy to read) rather than XML
development:adapter: ocihost: 192.168.0.50/examplesidusername: exampleuserpassword: examplepass
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Web 2.0 Features• Rich Internet application techniques, optionally Ajax-
based• CSS• XHTML markup and Microformats• RSS/Atom• Clean and meaningful URLs• Folksonomies (in the form of tags or tagclouds for
example)• Wikis, Weblogs, Mashups• REST or XML Webservice APIs
from wikipedia
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Other Rails-Like Frameworks• Groovy: Groovy on Rails -> Grails• Java: Trails• PHP: PHP on Rails -> PHP on TRAX• ASP.NET: Monorail (Beta 4)• Python: TurboGears (well, sort of)
This is another language/framework to watch out for.
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Disadvantages• No big corporate backer• Very few expert Ruby programmers, and universities
and TAFEs have not picked it up• Runs slowly (Java ~ 5 times faster but Ruby may be
improved by new VM - YARV)• Poor editor support and very slow debugger• No clustering, failover• No two-phase commit• Does not support compound primary keys• Internationalization support is weak• No off-the-shelf reporting tool
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Advantages• Standard directory structure for source• Can build prototype very quickly• Can add to and change prototype easily• Can generate scaffolding, if app is more complex, and
build on this• Very powerful, high-level commands• Ruby has great short-hand code for common patterns,
eg the Value Object• Built in testing, migration, and some version control• Does not constrain the programmer like other
frameworks
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Positive Signs• Ruby declared TIOBE's Programming Language of the
Year, 2006 (10th)• Agile Web Development with Rails - No 3 in Amazon’s
Best Books (Computers and Internet) 2006• JRuby - Ruby on JVM, being developed by SUN• Mac OS X 10.5 (Leopard) will have Ruby and RoR
pre-installed• IBM offers a Starter Toolkit for DB2 on Rails• Oracle have tutorials and a FAQ on RoR
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Defections from Java to Ruby• James Duncan Davidson (ANT)• Mike Clark (Pragmatic Automation)• Jason Hunter (Java Servlet Programming)• Bruce Tate (Bitter Java, Spring Dev Notebook)• Dion Almaer (Founder of theserverside.com)• Stuart Holloway (Component Dev for Java)• Justin Gehtland (Better, Faster, Lighter Java)• Glenn Vanderburg (Tricks of the Java Programming
Gurus)• David Geary (Graphic Java, Core JSF)
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Trivia
• Ruby was named after the birthstone of a colleague of Matz (birthstone of July)
• Pearl (Perl) is the birthstone of June
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
RoR in Baby Steps1. Read the Wikipedia entries on Ruby and
Ruby on Rails2. Read the Ruby / Ruby on Rails Cheat Sheet
http://www.blainekendall.com/uploads/RubyOnRails-Cheatsheet-BlaineKendall.pdf
3. Follow instructions to install tools and web serverhttp://ruby.meetup.com/73/boards/view/viewthread
?thread=2203432
4. Read the book to develop your first app!Ruby on Rails, Up and Running
8th February 2007
Ruby on Ruby on RailsRails
Bill Malkin
Conclusions• Can only be used for web-based, specifically HTML-based,
applications• Designed for small to medium CRUD-based applications• Cross-platform• A lot of hype (many evangelists)• Some dubious claims, very little expertise• Some very good, new concepts, some old with new names• Still missing some essential tools• Rails-type framework can certainly be applied elsewhere• Surprisingly large tools and software base• Ruby and Rails are each very powerful in their own right• Looks good!