If you’ve been hacking away in Ruby for a while and are looking to take your skills to the next level, our panel of seven Ruby experts has a few words of advice for you.
Below are some helpful hints, personal growth-inducing exercises, and tools recommended by some of the best Ruby devs out there. And of course, we welcome any tips or advice you have to give in the comments.
If you’re looking for advanced-level code snippets, stay tuned for the next installment in this three-part series on Ruby. And if you’re just starting out as a new Ruby dev, check out our tips for Ruby novices, which includes introductory-level advice from the same group of experts.
Jacques Crocker: Create a Library of Snippets
Jacques Crocker is a Rails Jedi based out of Seattle who loves working on early-stage startup ideas and launching new products. He’s helped launch almost a dozen Rails apps this year including HeroScale.com (automatically scale your Heroku workers and dynos) and WordSquared.com (a massively multiplayer online word game).
His advice for intermediate Ruby devs is to “build an executable snippet library.” He explained:
“Every time I write some code that I think could have potential for reuse in another project in the future, I copy and paste it into a unit test within a private ‘snippets’ project. This allows me to go back and pull out snippets of functioning example code whenever I confront the same problem again. The most important thing is that this code is executable, and has associated tests.
“Use this as a replacement for IRB [the Interactive Ruby Shell]. Instead of loading up an IRB instance to verify that some code works, I open up my snippets project in TextMate and start writing some unit tests to get the code working. Running these snippets within TextMate is even easier than IRB (
Yehuda Katz: Get to Know the Ruby Object Model
Yehuda Katz is a member of the Ruby on Rails core team, and lead developer of the Merb project. He is a member of the jQuery Core Team and a core contributor to DataMapper. He contributes to many open source projects, like Rubinius and Johnson, and works on some he created himself, like Thor.
He tells intermediate Ruby coders to “spend some time to properly understand the Ruby object model. Specifically, understand what
singleton classes are and how they are used.
“It’s possible to muddle along for a long time in Ruby without understanding it, but it will add a lot of complexity to your mental model, because you’ll be creating many imperfect abstractions in your mind when the reality is much, much simpler.”
Obie Fernandez: Go Easy on Metaprogramming
Obie Fernandez is the founder and CEO of Hashrocket, a Florida-based web consultancy and product shop. He’s a well-regarded blogger and speaker, and he’s also a series editor and book author for higher-education publishers Addison-Wesley.
For mid-level Rubyists, he advises them to not “go crazy” when it comes to metaprogramming.
“There is definitely a curve in your adoption of Ruby when you start getting comfortable with the core language features and start exploring some of the wilder possibilities. For me it was a little over a year in when I started doing a lot of DSL (Domain-Specific Language) stuff in Ruby.
“When you get into heavy usage of
instance_eval, friends, your code starts getting more and more difficult to understand and maintain. Yes, Ruby has incredibly powerful metaprogramming powers, but if you’re using them in your day-to-day application programming, I’m going to bet you’re doing it wrong.”
Ryan Bates: Use the Source, Luke
Ryan Bates is the producer and host of Railscasts, a site full of free Ruby on Rails screencasts.
“Don’t be afraid of diving into the source code when you don’t understand something,” is Bates’s advice to intermediate Ruby programmers.
“Ruby libraries are often lacking in the documentation department, but the code is generally readable. If there are tests, those can also help show you how the code is intended to be used.
“Reading other code is one of the best ways to improve your code as well.”
Desi McAdam: Dive Into IRB and Code Katas
Desi McAdam is a Ruby developer at Hashrocket. She also co-founded and regularly contributes to the technical blogging group DevChix.
McAdam says that for her personal growth as a Ruby developer, “Playing around in IRB is something that has helped me. One example of this is opening up classes, extending them, including them, etc., to see how the method calls happen in one way versus another. It really helped me understand when to use
extends versus when to use
She also said that code katas, études for programmers, have been extremely useful in helping her improve her Ruby skills. “There are a bunch out on the web, and it’s a really good way to beef up your Ruby knowledge because the exercises prod you into certain aspects of the language you might not otherwise hit in your everyday Ruby coding.”
Raquel Hernández: Follow Others’ Code and Conversations
Raquel Hernández is an experienced hacker/mathematician with a background that includes many programming languages and many work environments, from freelance and contract work to startups and larger companies. However, she’s made a particular focus of Ruby and Rails.
She said that reading and researching other developers’ code is the best way for an intermediate Rubyist to improve his or her skills. “Don’t just install a gem; look at how things work internally.
“Recently I started following Ruby Best Practices — Practicing Ruby, The Newsletter. It’s pretty good for intermediate or advanced Ruby devs.”
José Valim: Code Open Source Projects
José Valim is the founder of Plataforma Tec, a web development shop and consultancy. He’s also an open source developer and a Rails Core team member.
In addition to reading source code from other developers and other projects, Valim recommends that intermediate Ruby devs get involved with open source projects, themselves. “You can learn a lot by doing these activities… Ruby’s community is responsible for several open source projects, conferences, tutorials and blogs that improve and bring new ideas into the Ruby ecosystem every day.”
As an open source developer, he also encourages more women specifically to get involved in open source Ruby coding.
Specific Questions or Tips?
If you’re an intermediate Ruby dev and you have a question, feel free to drop it in the comments! Our panelists are likely to stop by with more feedback.
Likewise, if you’re a more experienced Ruby dev and you feel like answering questions or passing on some great advice of your own, please leave a comment and school us all.
Series supported by Rackspace
The Web Development Series is supported by Rackspace, the better way to do hosting. No more worrying about web hosting uptime. No more spending your time, energy and resources trying to stay on top of things like patching, updating, monitoring, backing up data and the like. Learn why.
More Dev & Design Resources from Mashable:
– The Top 8 Web Development Highlights of 2010
– HOW TO: Get More Out of Your Fonts
– 4 Predictions for Web Design in 2011
– HOW TO: Make the Most of TextMate
– 5 Free Annotation and Collaboration Tools for Web Projects
Image of José Valim courtesy of Flickr, levycarneiro.
For more Dev & Design coverage:
- Follow Mashable Dev & Design on Twitter
- Become a Fan on Facebook
- Subscribe to the Dev & Design channel
- Download our free apps for Android, Mac, iPhone and iPad