All Posts For: February, 2012

Feb 28 2012

Writing Readable Ruby

Ruby inherits the philosophy of “there’s more than one way to do it,” or TMTOWTDI, from Perl. Of course, TMTOWTDI is worthless unless at least a handful of those ways can be written clearly not just for the author, but (perhaps more importantly) for future readers and editors.…

Feb 26 2012

Category Pros and Cons

Objective-C categories are cool. They allow you do something that you can’t do in most compiled languages: add new methods to existing classes. You can even add methods to classes that you didn’t write.

Suppose you wrote some code to translate an ordinary string, like “Hello, perhaps I could enjoy a bit of your delicious sandwich over there?” to LOLcat speak, like “I can has cheezburger?”

In other languages you would probably subclass the String object and add a member function called -lolspeek which does the translation.…

Feb 24 2012

Rails and CanCan: Authorization for Specific Fields

A recent project we worked on at Highgroove involved scheduling events on a calendar. These events had a lifecycle of “statuses,” such as “pending approval” and “approved.”

All users were able to set the “status” to values such as “pending approval,” but only certain privileged users could move them to states such as “approved.”

We were already using CanCan for authorization, but there was no built-in facility for authorizing field-level changes.…

Feb 21 2012

Working Hard or Working Efficiently?

Companies often feel that they are getting the most out of their employees if everyone is working as hard as possible for as long as possible. However, this can be exhausting on the employees and can lead to diminishing returns. We feel that the better approach is to emphasize efficiency over effort, and our level of productivity speaks for itself.…

Older posts