2 years ago
Ruby Best Practices
a little book review
Ruby Best Practices (RBP) by Gregory Brown is unlike any previous book on Ruby written yet. I really like it. This is not a book of commandments, recipes, design patterns, or style guides. Rather this is a book that is designed to help intermediate Ruby programmers learn how to think about writing and analyzing software.
If RBP had a biggest strength it would be its case-study approach of looking at real-world Ruby software as the context for best practices. It is not a theoretical or hypothetical book but very practical. One of the premises of RBP is that best practices have a context—a time and place—and aren’t just rules we slap across everything indiscriminately. It is meant to spur dialogue and provoke thought. It will help give you a new set of eyes as you read through Ruby source code (which brings up another premise of RBP—you should be learning by looking through the source code of real projects).
If RBP had a biggest weakness, it would be that it was written by one guy with help from a few others and it is limited to their observations and experience. Not everything is covered nor can it be. Somebody will complain that it is not complete but Gregory has sort of preserved himself from that sort of fault-finding by presenting this more as a “one side of the diamond” than a “here are the best practices, follow them” approach.
I think that RBP is important for the Ruby community not because it contains the solutions to everyone’s problems but more because it can serve as a great launching point for important discussions that will help us to think through the Ruby software we write and how to glean from the outstanding solutions other Rubyists smarter than ourselves have come up with.
I like the way this book is organized for the most part. The chapters are topical and focused and can be read in any order according to what is most interesting to you at the moment. There is a lot of code in this book and doesn’t make for an easy skim—you should just know that. I got the most out of this book when I had my text editor open and tried out some of the ideas as I went along.
One of my favorite O’Reilly books is Perl Best Practices by Damian Conway (go ahead and tease). I expected this book to to take a similar format—PBP is categorized into chapters and sub-divided into about 100 core principles such as “Use croak instead of die”, “Use hashes for arguments > 3”, and so on. RBP is not organized like that at all—perhaps because it would not serve Ruby developers as well… I don’t know.
It should be mentioned RBP is a Ruby 1.9 “moving forward” book and will hopefully remain relevant longer.
RBP is very rich with ideas and perspectives and examples but there are also a lot of simple takeaways that will stick with me as long as I write code in Ruby. Though it is rich and probably not a book you can master in one reading there are many nuggets and tips that will give you immediate gratification. Some of these tips seem so minor but they amount to be the things that save us tons of time (see Chapter 6 “When Things Go Wrong” on making the most of Ruby’s reflection for debugging). You should check it out, read it in your user group or dev team and discuss it. I really think we need more of these type of practical best practices books and blogs and case-studies and discussions and I am glad for the appearance of this book.
3 years ago
I sat down in the library one day to imagine what the Rails 3 logo should look like. I came up with this in about 15 minutes of experimentation.
The ‘powered by Merb’ thing at the bottom is just a joke I came up with toward the end. I don’t mean anything political by it.
FAQ #2: Why is ‘powered’ spelled wrong?
I mistyped it a little the first time I typed it in and saw the correspondence of the syllables ’erd’ and ‘erb’ and since there is strong precedent for deliberately misspelling things on the internet, I decided to go with something along those lines.
Rails 3 made me think of 3 as in “Three Dimensional”. I’m sure there has to be some cosmic significance to it somehow, right? So anyway, I don’t have red/green 3D glasses but I suspect it would make this logo look pretty cool.
I don’t see any other Rails 3 logos around yet is this the best one you’ve seen?
Ruby on iPhone (sorta).
This deserves some explanation. I posted this on my facebook account and people where like, ‘whaaa?’. It looks crazier than it is and I really haven’t found too much application for it especially since typing all the ‘([*>=’ characters can get annoying before it gets practical. Still it is fun, and irb works which is nice for testing things quickly.
Simple Steps:
1) Default iPhones have their arms tied and are not fun hacker toys until they are ‘freed’. The brave can start here http://www.quickpwn.com/ but make sure everything is backed up so you can recover if things go wrong.
2) Read this: http://www.saurik.com/id/1 it is the story of how a guy ported Debian apt-get to the iPhone, put a friendly face on it with UIKit (called Cydia). You can add package sources to apt-get and install new stuff either through the command line ‘apt-get install ruby’ (as root) OR just use Cydia (it’s simple and nice, you can uninstall stuff and update packages with it too). You can install Cydia by using QuickPwn then look for Ruby under Browse > Scripting.
3) I already gave it away but you can ‘apt-get install ruby’ (as root) with the Terminal app.
4) Test it. ‘ruby -v’.
A Short Example:
1) Type ‘irb’ to invoke Ruby’s interactive interpreter.
2) Try a simple script using ‘open-uri’.
» require ‘open-uri’
» page = open “http://ghettochip.com”
» puts page.readlines
3) Think of cool stuff you can do with Ruby on your iPhone and push this further.
