18 Jul '12, 2pm

A questionable use of Null Object pattern; a typical Advanced Beginner approach.

April 11, 2012 Tagged: patterns refactoring null object Comments (View) Rails Refactoring Example: Introduce Null Object You probably don’t write code like this: if object.kind_of?(User) do_this else object.do_that end Why not? Because Ruby encourages duck typing and polymorphism. A hidden version Here’s the same principle: if object.nil? do_this else object.do_that else This checks that object is of type NilClass instead of type User . The pattern There’s an old pattern called Null Object that addresses this special case of avoiding type-checking in favor of duck typing. Here’s an example of the “Introduce Null Object” refactoring to fix this problem with a Null Object in a Rails app. The code to be refactored Airbrake reports an error from this line in a Haml view: = l location.orders.ascend_by_created_at.first.created_at.to_date Demeter is displeased but let’s fix the p...

Full article: http://robots.thoughtbot.com/post/20907555103/rails-refac...

Tweets

Refactoring with Hexagonal Rails

rubyflow.com 17 Jul '12, 1pm

Refactoring with Hexagonal Rails Posted by gma on July 17, 2012 — 0 comments I've been applying ideas from Matt Wynne's He...

Awesome: Object#returning #rails

apidock.com 23 Jul '12, 8am

to the block. This simplifies the process of constructing an object, performing work on the object, and then returning the...

Object#returning - Replacement #rails

apidock.com 23 Jul '12, 7am

to the block. This simplifies the process of constructing an object, performing work on the object, and then returning the...

Design Patterns in the Wild: Null Object — gian...

robots.thoughtbot.com 23 Jul '12, 6am

November 1, 2011 Tagged: ruby design patterns factory girl null object pattern Comments (View) Design Patterns in the Wild...

[Event] August 03rd, 2012 - Psychology of Promo...

whatshappening.sg 30 Jul '12, 4pm

You are about to learn strategies that the general public will never know about on – How to get your boss to recognise you...

What's New in Edge Rails

afreshcup.com 25 Jul '12, 2am

is Mike Gunderloy's software development weblog, covering Ruby on Rails and whatever else I find interesting in the univer...