Adapters turn out to be especially powerful at the boundaries of our applications. They can shift the shape of an open source library and shield the internals of an application from changes to these libraries.

Last Move: Keep creation and interaction apart

When interaction is independent of creation, an implementor can be replaced with another without affecting the interaction.

This lets us change the behavior of our system more easily, has immediate benefits in test isolation, and also leaves room to discover uses our younger selves might not have imagined.

In combination, these 3 simple moves let us reconnect existing dots to draw new pictures. Each picture apt for its time.

]]>http://pivotallabs.com/vibrant-go-3-moves/feed/1Hash#fetch with confidencehttp://pivotallabs.com/hashfetch-with-confidence/
http://pivotallabs.com/hashfetch-with-confidence/#commentsSun, 05 May 2013 19:04:58 +0000http://pivotallabs.com/?p=18817Hash#fetch is stricter about key presence than Hash#[] {}[:foo] => nil {}.fetch(:foo) KeyError: key not found: :foo If you forget to set an ENV variable, would you rather your application fail late or immediately? ENV['TWITTER_OAUTH_TOKEN'] => nil ENV.fetch('TWITTER_OAUTH_TOKEN') KeyError: key not found It’s especially interesting when a key with a truthy default is explicitly ...

This is likely because the project included a submodule that wasn't configured correctly, fix this in under Rubymine's version control preferences.

Interesting Things

Test 404 handling (e.g. rescue_from ActiveRecord::RecordNotFound, :with => :render_record_not_found) with Cucumber by temporarily setting ActionController::Base.allow_rescue = true. This is usually set to false in features/support/env.rb

This is likely because the project included a submodule that wasn’t configured correctly, fix this in under Rubymine’s version control preferences.

Interesting Things

Test 404 handling (e.g. rescue_from ActiveRecord::RecordNotFound, :with => :render_record_not_found) with Cucumber by temporarily setting ActionController::Base.allow_rescue = true. This is usually set to false in features/support/env.rb

Suggestions included Chronic and RI_CAL though I'm hoping for something that can represent arbitrary periods (ranges?) of time JODA and handles interval calculation and other such date/time arithmetic.

Suggestions included Chronic and RI_CAL though I’m hoping for something that can represent arbitrary periods (ranges?) of time JODA and handles interval calculation and other such date/time arithmetic.

One team noticed an odd error when they mistyped a Thor constant name.

ArgumentError: Thor is not missing constant Sandbox!.

This appears to due to how #const_missing in activesupport handles nested constant names. Specifically when trying to reference one nested constant from within another nested constant that isn't its parent:

Curiously the spec that exposed the previous issue also returned this odd summary:

One team noticed an odd error when they mistyped a Thor constant name.

ArgumentError: Thor is not missing constant Sandbox!.

This appears to due to how #const_missing in activesupport handles nested constant names. Specifically when trying to reference one nested constant from within another nested constant that isn’t its parent:

Curiously the spec that exposed the previous issue also returned this odd summary: