Ruby Best Practices: A Review
One of my favorite simple pleasures is reading a technical or instructional book where the level of complexity perfectly matches my expertise. I've been enjoying this exact experience while reading Greg Brown's new book, Ruby Best Practices.
I have been programming professionally for over three years, with the last five months doing full time Ruby on Rails development. I would label myself an intermediate Ruby user: comfortable with the basics, but with limited exposure to its more advanced topics. Lately, I have been reading more and more open source Ruby projects, and have been looking for ways to contribute back to our teriffic community.
Given my experience and goals, Ruby Best Practices was a perfect read. The book is a collection of general strategies for solving problems in Ruby, with a focus on real-world code examples. Its author is an experienced Ruby developer who also happens to be an excellent writer.
Ruby Best Practices has a number of notable strengths. First, Brown is highly pragmatic. When discussing closures, he writes "I could show some abstract examples or academically exciting functionality such as Proc#curry, but instead, I decided that I wanted to show you something I use fairly frequently." This attitude has lead to a book that is full of ideas you can actually use. It feels like the experienced guy down the hall showing you all his best stuff.
Secondly, RBP's examples are almost uniformly excellent. As contributor or creator of several popular Ruby projects (Prawn and Ruport) Brown has no lack of real-word code examples to choose from, and he does so with skill. In addition, he's not shy about trimming down the examples to leave behind just the most relevant code elements. These two factors combine to produce code listings which are indicative of real open-source programs while remaining quite comprehensible. Not only are Brown's examples excellent, but they are plentiful. Nearly every new idea he introduces is demonstrated through a case study of real (or plausibly real) code. Working through this book will definitely sharpen your code-reading skills.
Beyond simply being clear, Brown's writing is also fun to read. His enthusiasm for the subject matter is obvious: "I could stop here and move on to the next topic, but similar to when we looked into the belly of lazy.rb earlier in this chapter, I can't resist walking through and explaining some cool code." This sort enthusiasm continues throughout, and leads to a technical book that I'm tempted to call a page-turner. Making my way through the book really excited me to read and work on open-source projects.
If you're still on the fence, take a read through the sample chapter, Mastering the Dynamic Toolkit. Or, if you'd prefer a quicker read, check out this post on the book's blog to get a feel for Brown's writing style. If you like what you see, don't hesitate to pick up a copy of this excellent book.
Chapter Titles:
1. Driving Code Through Tests
2. Designing Beautiful APIs
3. Mastering the Dynamic Toolkit
4. Text Processing and File Management
5. Functional Programming Techniques
6. When Things Go Wrong
7. Reducing Cultural Barriers
8. Skillful Project Maintenance
A. Writing Backwards Compatible Code
B. Leveraging Ruby's Standard Library
C. Ruby Worst Practices