21 Dec '13, 3am

Dependency Injection Matters

I like using command objects as the ‘crux’ of my controllers. They encapsulate behavior without making models or controllers thick. I think of commands as reactions to a signal (event). To produce a command I think first of the signal it is responding to. Let’s use an example: class WidgetController < ApplicationController # We're assuming there's sufficient complexity in publishing # a widget to warrant a command. def update publish_command.execute(params[:widget]) if params[:publish] end private def publish_command Widget::PublishCommand.new(WidgetParamsParser.new) end end The ‘signal’ that WidgetController emits is ‘Publish the widget’. It sends the only thing which is topical to this signal, the widget in question. This is a contextual dependency. The command inverts control, passing it a parameter parser that knows how to deal with the representation used. This is a c...

Full article: http://pivotallabs.com/structuring-commands-clarity/

Tweets

The World Needs Another Post About Dependency I...

rubyflow.com 17 Dec '13, 11am

The World Needs Another Post About Dependency Injection in Ruby Posted by solnic on December 17, 2013 — 0 comments ...and ...

Why Inequality Matters

anwaribrahimblog.com 16 Dec '13, 3am

Rising inequality isn’t a new concern. Oliver Stone’s movie “Wall Street,” with its portrayal of a rising plutocracy insis...