Want to reuse variable and not pollute scope? Meet Object#tap()

This is my latest favorite, little, neat feature (it appeared around ruby 1.9 but the idea is simple, and it can be implemented in any decent language*… No php, you can’t play that game – too difficult for you). For older rubies you can monkeypatch it, but you should probably upgrade – with tests it’s really simple.

so you have

set :foo, "/home/me/foo"
set :bar, "/home/me/foo/bar"

you want to keep it DRY, so

home = "/home/me/";
set :foo, "#{home}foo"
set :bar, "#{home}foo/bar"

but one of the option to avoid polluting namespace with home variable is to use tap() method:

"/home/me/".tap do |h|
  set :foo, "#{h}foo"
  set :bar, "#{h}foo/bar"

Object#Tap is really simple and useful. For every object it takes block as an argument, and this block have one variable (the object itself), and whatever you do – it returns it. So, as name suggests, you can tap into any place in your method chain and inspect what is going on there. Take a look in docs example.

(*) By decent language I mean one which would allow you to introduce such feature in base Object class. In others you’re stuck with making decorators or some special objects just for that. In others maybe you have a chance, but in php you’re doomed:

Share Button

Audiobooks? I can recommend somethig.

Last two promos on audible really boosted up my library: got 5 new books just for 3 credits.

Didn’t try audio-books yet? What do you do when dish washing, commuting or knitting?

I can recommend audible gold membership: for 15$ you’ll get 1 credit each month; and can buy 1 book for 1 credit. Many of them much more expensive that 15$.

Many of the books I’ve always wanted to read are appearing there as audios – cool.

Two of my favourite I’ve already read and can definitely recommend:

This Will Make You Smarter: New Scientific Concepts to Improve Your Thinking 

The Modern Scholar: World of George Orwell

Stuff I can’t wait to listen:

How the West Won: The Neglected Story of the Triumph of Modernity

How Wars End: Why We Always Fight the Last Battle

Agent Storm

Share Button

Rules for best analyst ever

As a follow up to “how to hire best analyst” here are some factors I think are important to organize your company this way.

Allow your team to be us vague with estimation as they please (don’t hold it against them).

I’m positive and maybe little bit romantic if it comes to human nature. I believe devs gives big estimations in two cases: when the feature is big or when there’s too many question marks around it. The former tends to be underestimated, the latter – it’s mixed, but it’s not uncommon to see the estimated work shrinking along the way, when the intentions are uncovered.

I’ve never experienced big estimation because dev team was lazy and wanted to take a little rest next sprint.

Anyway your team will be precise when requirements are clear.

Other trick you can use is to ask estimates with error margin. In general you will be getting X+/-10% (where X is an estimate). But the +/- part can hold an information with how much uncertainty devs are dealing with. It will be non-zero all the time because shit happens and devs know it. But when it grows to ridiculous – there’s much uncertainty there.

I use estimates with uncertainty margin only for pre-estimates: it’s not story for next sprint, but PO wants to know how much (more or less) something will take. So they can make rough plans.

Allow them not to start working when not enough resources available

And mentioned resources are most often information. This is not always possible. Our solution is clear information (with some CC to important figure in the e-mail if needed): “ok guys – we’ll start working on feature Foo despite not having all the information. But please keep in mind it is possible we’ll need to throw everything to trash later, because we’ll make guess-assumptions – we’ll be flipping coins”.

On the side note: I’m sometimes harsh when it comes to communicating such messages. But the goal is not to feel nice – my goal is that everyone understand. Like this flipping coins – I would say that as I mean it. But of course down the road we would ask PO any time it makes sense. I just want them to feel this chill on their necks for a moment.

Teach everybody that code is not gold mined from deep underground

You don’t need to store as much as you can. It’s ok to throw it our. (this is difficult part for devs)


much hard work

I actually feel the best when I can remove a lot of code.

For this you would need someone who can take lead and who live by that principle. Someone who feels secure enough – so he can comfort your team when that happens.

This is not all, probably there are some small nuances which I don’t see. If something comes to my mind – I’ll share. Please to that also in the comments.

Share Button