Jared Richardson
Posts: 1031
Nickname: jaredr
Registered: Jun, 2005
|
Jared Richardson is an author, speaker, and consultant who enjoys working with Ruby and Rails.
|
|
|
|
Ruby is so cool
|
Posted: Feb 23, 2006 7:45 PM
|
|
|
This post originated from an RSS feed registered with Agile Buzz
by Jared Richardson.
|
Original Post: Ruby is so cool
Feed Title: Jared's Weblog
Feed URL: http://www.jaredrichardson.net/blog/index.rss
Feed Description: Jared's weblog.
The web site was created after the launch of the book "Ship It!" and discusses issues from Continuous Integration to web hosting providers.
|
Latest Agile Buzz Posts
Latest Agile Buzz Posts by Jared Richardson
Latest Posts From Jared's Weblog
|
|
I'm going through Dave and David's Rails book and parts of it just amaze me. How much code would it take in your language of choice to do the following:
-
Pull all the data from a database table
-
Filter out the data by some value on a single column
-
Sort the data
Granted, this isn't rocket science. Any beginner programmer should be able to do this. But in the Rails book, it's four lines of code... and it could be one. It's written on four lines to be readable.
This is a routine that returns all the items that can be sold now. Can you read it?
def self.salable_items
find (:all,
:conditions => "date_available <= now()",
:order => "date_available desc")
end
I know, some of the magic is ActiveRecord, the Ruby OR layer... but in my mind I'm running through all the JDBC driver trappings, the selects, the sorting. Maybe if I'd tinkered with Hibernate, I'd know a four line way to do this in Java. Maybe....
Jared
Read: Ruby is so cool
|
|