Tag Archives: oo

Early access beta of “Objects on Rails” Now Available

Often, at conferences and users group meetings, I find myself discussing the intersection of Ruby on Rails, Object-Oriented development, and Test-Driven Development, and I’ll mention something like “I prefer to develop my business objects first, and add ActiveRecord in later”. This usually leads to … Continue reading

Posted in Announcements, Books | Tagged , , , , | 21 Comments

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 , , , , , , , , , , , , | 67 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

Checking the existence of a super method in Ruby

Ruby gives methods the ability to call up to the superclass definition of themselves. Or it may not be a parent class definition; it might call up to a definition in a module included further up the ancestor chain. Either … Continue reading

Posted in Howto, Ruby | Tagged , , | Leave a comment

Testing Private Methods

Periodically the question of how to test private methods comes up at work or online. My answer is: don’t. It may seem trite, but there is some reasoning behind it. Private methods are, by definition, implementation details. If you are … Continue reading

Posted in Uncategorized | Tagged , , , , | 8 Comments