Tips on how to improve application efficiency

Rails performance specialist Stefan Kaes, who writes extensively about optimizing Rails over at Rails Express has a lengthy article at the new InfoQ site called A Look at Common Performance Problems in Rails.

Kaes identifies various development practices that will slow down your Rails applications, such as repeating computations that only need to be run once and then cached. If you’ve located some slowness in your application, Kaes may have already identified some of the likely culprits.

Remember CRC Cards?

In 1988, Ward Cunningham (yes, that Ward Cunningham) came up with an idea to use index cards as a tool for object-oriented design. I was working for Kent Beck at Apple at the time, so I got to hear Ward describe his idea over speakerphone in Kent’s office. Ward and Kent presented a paper on CRC cards at the OOPSLA conference the next year, and suddenly they were all the rage. Some companies even printed up branded CRC cards, which still makes me laugh.

Take an index card. (3x5 or 4x6 are good sizes, but any larger than that and they become too unwieldy to move around.) Write the name of a class across the top. Draw a vertical line separating the rest of the card into uneven halves - the left half should take up about 2/3 of the width. On the left side write the responsibilities of the class. On the right side write the objects or classes of objects that objects of this class collaborate with. That’s the basics right there. Once you have cards representing several classes, you can arrange the cards to explore object interactions and discover new responsibilities and collaborations.

While CRC cards can be used solo, where they really shine are during collaborative design. It’s easy for one person to move a card around to show others what they mean. Since cards move independently, two people can be writing on different cards at the same time. It makes for a lightweight yet effective group design process. It’s also a decent way to describe a design.

CRC cards also play well with the Rails mindset where constraints are empowering. Cards are small, so you can’t write so much on them that they become too complex to understand. Limited space keeps you focused on the important stuff. And since cards are easy to make, they are also easy to throw away - no investment equals no pain. Don’t like what’s on a card? Just tear it up and start over.

A good way to start with CRC cards is to use them to document an existing design. That way you don’t have to deal with creating a design while learning a new tool at the same time. Then you might use them to modify or expand the design for existing software. Once you are warmed up with them you can take them for a spin on a brand new design.

My brief explanation hardly does the topic justice. Read Ward and Kent’s paper, explore the original wiki for CRC card articles, and of course google around for yet more information.

New from O'Reilly: RJS Templates for Rails

Cody Fauser has just announced the release of his PDF-only book RJS Templates for Rails.

From almost the day we checked rjs into the repository, Cody was quickly singling himself out as an expert. When he found out they weren’t going to make the 1.0 release, he made an rjs plugin available for those staying back at 1.0. Before we had extensive documentation, he was doing the dirty work, putting together various tutorials and explanations. Many of you likely learned about rjs from Cody. And now, many more of you likely will too.

Jaded Pixel wisely brought him onto their team. He’s applied his rjs skills to great effect on Shopify.

As a reviewer of RJS Templates for Rails, I can attest to it being comprehensive and up to date. The book provides a tutorial style guide to using rjs then at the end there is a full reference. Most impressively, Cody is a solid technical writer. I’m quite sure this is his first book yet it reads like it was written by someone who’s been doing this for years. I hope it’s not his last.

You can get a copy for 9 bucks.

Rails System Back on Track

Hopefully you didn’t notice, but I’ve been very busy this weekend. I finally took the plunge and got all the Rails applications that run on this machine up to snuff. All applications hosted here are now deployed with Capistrano, run under Mongrel (using the mongrel_cluster plugin) with requests being handled by Apache 2.2 and proxied to Mongrel by the mod_proxy_balancer module. So far it seems to be working great. You’ll notice that the Wiki, the Manuals and the weblog are all much zippier. The machine seems to be much happier as well.

And, to cap off all this fun, the weblog has been migrated from Typo to Mephisto, the blog/CMS engine from Rails Core member Rick Olson. The feed has also been moved to FeedBurner and redirects have been put in place so your reader should make the change automatically. If not, just subscribe here.

Thanks to everyone who helped me check and test things! Trac improvements are next on my list. Stay tuned!

Patience, Grasshopper

We all know that for some time this blog has needed some love. Well at last it can be told: There’s been a super-secret project underway for a while to upgrade the blog and get it running the way it should. We didn’t want to make a huge deal of it, but it seems that a few overly enthusiastic readers really enjoy posting bug reports as comments. So just chill out – the upgrade is coming soon. Posting thousands of comments isn’t going to make it happen any faster.

Browse your Subversion Repositories

Bounty Source provides the Open Source community with free hosting and tools including a task manager, a CMS, and a Subversion Code Repository. They’ve been gracious enough to release the Subversion Browser as a Rails plugin.

I’ve posted a technique on Rails Weenie on using your application’s authentication scheme on the plugin, so that your secret sauce is not available to the whole world.

Shopify is open for business

We’re lagging the official announcement by a fair margin, but that won’t hold back our official word of congratulations for Jaded Pixel as they’ve launched Shopify. It’s instant-on stores that don’t smell like a candy bar left in your pocket in the mid-90’ies. Complete with its own templating engine, Shopify makes it silly easy to create great looking stores that doesn’t just follow a cookie-cutter format.

In Rails circles, Jaded Pixel is mostly known as the company starring Rails Core developer Tobias Lütke. The team has already been sharing a great many extractions from the work of Shopify. So if you’ve played with the template engine Liquid or installed the forum-system Opinion, you’ve been touched by Shopify (now isn’t that heart warming!).

Once again, major props to Tobi and crew for finally delivering on this massive undertaking.