powerpoint file - acs (australian computer society) - membership

26
8th February 2007 Ruby on Ruby on Rails Rails Bill Malkin

Upload: sampetruda

Post on 08-May-2015

2.103 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: PowerPoint File - ACS (Australian Computer Society) - Membership

8th February 2007

Ruby on Ruby on RailsRails

Bill Malkin

Page 2: PowerPoint File - ACS (Australian Computer Society) - Membership

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!

Page 3: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 4: PowerPoint File - ACS (Australian Computer Society) - Membership

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.

Page 5: PowerPoint File - ACS (Australian Computer Society) - Membership

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]

Page 6: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 7: PowerPoint File - ACS (Australian Computer Society) - Membership

8th February 2007

Ruby on Ruby on RailsRails

Bill Malkin

Available Information

Page 8: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 9: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 10: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 11: PowerPoint File - ACS (Australian Computer Society) - Membership

8th February 2007

Ruby on Ruby on RailsRails

Bill Malkin

A P

eak

at R

ails .

Page 12: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 13: PowerPoint File - ACS (Australian Computer Society) - Membership

8th February 2007

Ruby on Ruby on RailsRails

Bill Malkin

Rub

y on

Rai

lsR

eque

st F

low

Page 14: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 15: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 16: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 17: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 18: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 19: PowerPoint File - ACS (Australian Computer Society) - Membership

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.

Page 20: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 21: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 22: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 23: PowerPoint File - ACS (Australian Computer Society) - Membership

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)

Page 24: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 25: PowerPoint File - ACS (Australian Computer Society) - Membership

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

Page 26: PowerPoint File - ACS (Australian Computer Society) - Membership

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!