Tag Archives: patterns

Decoration is best, except when it isn’t

I think by now we all know to prefer composition over inheritance. But in a language with a lot of options, what’s the best kind of composition to use? Composing an adventure Consider an adventure game, with objects representing player … Continue reading

Posted in Ruby | Tagged , , | 9 Comments

SBPP #4: method Cascades

In Smalltalk, you can “cascade” side-effectful calls to the same object using the semicolon (;) operator. E.g.: If I understand it correctly, the semicolon is effectively a K-combinator or “Kestrel”. I am jealous. Sure, we have Object#tap, but that’s awfully … Continue reading

Posted in Smalltalk Best Practice Patterns | Tagged , , , , | 7 Comments

SBPP #3: Reversing Method

I’m pleased to find Kent Beck shares my affinity for methods with a consistent cadence. In the next pattern I translate, he looks for a way to bring a uniform rhythm to a method that writes an object to a … Continue reading

Posted in Smalltalk Best Practice Patterns | Tagged , , , | 2 Comments

SBPP #2: Smalltalk Patterns in Ruby

Smalltalk Best Practice Patterns continues from the introduction with a brief explanation of patterns. Some notable quotes: About leveraging commonality: “large-scale software re-use has not proven to be the answer”. A lot of the mid-90s OO PR centered around the … Continue reading

Posted in Smalltalk Best Practice Patterns, Uncategorized | Tagged , | 4 Comments

SBPP #1: Introduction

The Ruby Rogues are reading Smalltalk Best Practice Patterns for next month’s book club, so I finally got around to ordering a copy. It’s high time, considering that in my experience it’s one of the most consistently recommended programming books … Continue reading

Posted in Smalltalk Best Practice Patterns, Uncategorized | Tagged , | 4 Comments

Your Code is My Hell

It occurred to me recently that my experience as a Rails developer may be somewhat unique. I often get brought in to help preexisting Ruby/Rails projects evolve and mature in a sustainable way. As a result, the vast majority of … Continue reading

Posted in Rails, Rants, Ruby | Tagged , , , , , | 121 Comments

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 , , , , , , | 18 Comments

Null Objects and Falsiness

Thank you to Ben Hamill for sending me a question that prompted this post. Checking for object presence Very often in Ruby code, we would like to execute some action only if an object is present: def slug(title) if title … Continue reading

Posted in Ruby | Tagged , , , , , | 30 Comments

Linkdump #3

Conduce From Ara T. Howard, "a model+view component for rails that combines the conductor and presenter pattern via a model capable of generating view-centric methods". A single Gist which is interesting both for what it does, and for the way it … Continue reading

Posted in Resources | Tagged , , , , , , , | Leave a comment

Full Exploitation

“Full exploitation” is essentially a pattern in itself, and one we will come back to repeatedly. Whether it is applied to software development, architecture, or music composition, exploiting a good idea repeatedly can enhance the integrity and cohesion of the … Continue reading

Posted in Uncategorized | Tagged , , | 2 Comments