Books and Screencasts
Objects on Rails
A developer notebook on applying classic Object-Oriented principles to Ruby on Rails projects.
-
-
Recent Posts
Recent Comments
- newz2000 on The sorry state of video hosting for WordPress blogs
- Jheriko on Underscores are stupid
- Jason Dixon on Underscores are stupid
- Zecc on Underscores are stupid
- Kurt Werle on Underscores are stupid
Archives
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
Categories
Meta
Category Archives: Ruby
Do we need constants?
This article by Joey Butler about constants in Ruby got me thinking. How much do we really need constants, anyway? As Joey points out, constants are an opportunity for implementation details to leak out into other classes. But they complicate … Continue reading
You Can’t Subclass Integers in Ruby
This post is mainly just an excuse to test a Gist plugin for WordPress. Occasionally, you might think it would be handy to subclass Numeric types such as Integer. For instance, you might want to create a constrained integer which … Continue reading
Loading plugins with Rubygems
Let’s say you have a Rubygem named “blorf”. You want to enable other developers to write plugins in the forms of Rubygems of their own. For the end user, loading the plugins should be as simple as writing: require ‘blorf’ … Continue reading
Fowler on Rails
Projects using Ruby on Rails often lack strong distinctions in two main areas: The model/record conflation: Seeing “models” as strictly DB-backed resources. The view/template conflation: failing to draw a line between view objects and HTML templates. The conflations are encouraged … Continue reading
Posted in Ruby
Tagged activerecord, datamapper, Martin Fowler, patterns, Ruby on Rails, templates, two step view
18 Comments
The Procedure/Function Block Convention in Ruby
Ruby lets you enclose blocks in either {…} or do…end delimiters. Which you choose is a matter of style. There are two conventions that I know of for deciding which form to use. The one I see people using most … Continue reading
An intro to throw and catch in Ruby
I’ve got a guest post up at the RubyLearning blog today, an introduction Ruby’s throw/catch construct. It’s a bit more novice-oriented than the stuff I typically post here. Here’s an excerpt: If you’re familiar with Java, C#, PHP, or C++, … Continue reading
Demeter: It’s not just a good idea. It’s the law.
Is #try really so bad? In response to my recent post about #try being a code smell, a lot of people made the reasonable objection that the example I used—of using #try on a a Hash—was a pathological case. A … Continue reading
Posted in Ruby
Tagged bdd, coupling, demeter, design, law of demeter, objects, oo, oop, ruby, Ruby on Rails, structural coupling, tdd, testing
67 Comments
Do, or do not. There is no #try.
One of the ways you know you are working in a good language is that it makes bad habits ugly. To wit: # params[:foo] might be missing value = params[:foo].try(:[], :bar) This is not pretty. It is, as my dad … Continue reading
Your code is broken, and Ruby can help you fix it
Ruby is in many ways a better Perl, and it inherits a lot of its culture from the Perl community. One of the lessons I remember being hammered into my head early in the Perl community was the importance of … Continue reading
A Guardfile for Redis
I ran into a project that required a running Redis server for the tests and development environment to work. Here’s what I threw into the Guardfile to make sure a Redis server was running during development. It starts a new … Continue reading

