noizZze

Weekend Ruby: Coding Quality With Style


Photo by pdxnielson

It seems the community has started to work towards a common set of guidelines for a beautiful and readable Ruby code. Nice…

The idea behind any style guide is largely based on aesthetics and readability. The number of spaces to use for indentation, how to break statements into several lines, when the chain of statements is to be broken into several clauses – all is simple, yet no less important than the code itself.

These days we have many self-taught programmers who neither have a taste nor any special education. What’s worse, many of them don’t really care about clarity and maintainability of their code, preferring to quickly throw some pieces together to get their payments quickly without any proper design, testing, formatting and anything else. It’s a “poor job” and a “job poorly done”. I encourage everyone who purchase code to demand The Quality, and I equally encourage everyone who produces code to do their homework – study the best code samples, read guidelines, do their testing and follow (if not all, but as many as possible of) the best established practices. It’s the hard work that eventually becomes fun.

Here’s one of the attempts to summarize good coding practices into a guideline that I stumbled upon this week: The Elements of Ruby Style. It’s obviously incomplete, but it’s a good start that has all chances to evolve. There always will be people who disagree with certain points (including me, who would rather use “boolean ? 3 : 5” instead of “if boolean then 3 else 5 end”, which is redundantly complex), but if you need to start from somewhere, it still is a great starting point.

In the same vein, here’s Rails Code Quality Checklist and the Code Quality Checker. These are mostly for the code design control, but since we talk about code quality today…

Enjoy your weekend studies!