codegourmet

savory code and other culinary highlights

Trivariate Estimates

As developers, we often are the (only) ones who know how difficult or easy a task might be to implement.

We are able to cause business harm by underestimating a complex task. Also, constantly overestimating can sabotage the viability of an enterprise.

Don’t underestimate estimates!

Ruby: Capturing and Mocking Stdout

Sometimes, you want to assert that a method under test outputs some specific information to stdout. Or you want to silence all stdout from a library gone rogue (this happened to me once when I had to include a third-party library into a ruby C extension gem).

I wrote a Gem that does this, and MiniTest and RSpec already have matchers for this:

Vim: Staying on the Base Line

Staying on the touch-typing base line (a, s, d, f, ..) is strongly promoted by the Vim movement keys - but :w, ctrl, escape and more tend to distract my hand position. Here are some of the steps I took to deal with this:

  • map , to Leader
  • map Space to ^
  • map Control-m to save all
  • dual-map Caps Lock
  • map jj to Escape in insert mode
  • remap window focus movement
  • map Escape-Escape to nohlsearch

Unmasking Exceptions

Raising core StandardErrors can mask bugs in your code layer. But even re-raising exceptions from deeper service layers can mask errors that have nothing to do with the current exception use case.