Third Day of the Craftsman Swap
Day Three of the Craftsmanship Swap:
Micah and Paul had to head out of town for an Iteration Planning Meeting/Demo so it was just Colin Jones, Eric Meyer, and I in the office. We decided to do some tri-ping pong development on an internal product 8th Light is planning to release soon. So Eric would write a test/spec, I'd make it pass and write another spec, then Colin would make my spec pass and write one for Eric and the whole process would repeat. An enjoyable way to work made easier by their 24inch Cinema Displays and wireless keyboards.
I've noticed that everybody shakes hands at 8th Light. A lot. When someone arrives in the morning the new person tends to shake the hands of all who are already there. The same thing happens when someone leaves for the day. I asked Colin and Eric about the origins of this but they had no answers for me. It seems kind of weird, but it's also sort of a cool affirmation of camaraderie. It may just be better than the grunt I give people when they leave for the day.
At some point I found myself arguing for these lines of Ruby today:
return false unless coupon = Coupon.find_by_token(session[:coupon_token])
return coupon.active?
Instead of a 5-6 lines of if/else code. Have I become the very person I despised when I got into Ruby? That guy who can't rest until lines of code have been reduced to unreadable terseness? Even inject doesn't look so bad to me anymore...
Of course, if we were using a current version of Rails we could do this:
!!Coupon.find_by_token(session[:coupon_token]).try(:active?)
Now that's teh hotness.
Micah and Paul had to head out of town for an Iteration Planning Meeting/Demo so it was just Colin Jones, Eric Meyer, and I in the office. We decided to do some tri-ping pong development on an internal product 8th Light is planning to release soon. So Eric would write a test/spec, I'd make it pass and write another spec, then Colin would make my spec pass and write one for Eric and the whole process would repeat. An enjoyable way to work made easier by their 24inch Cinema Displays and wireless keyboards.
I've noticed that everybody shakes hands at 8th Light. A lot. When someone arrives in the morning the new person tends to shake the hands of all who are already there. The same thing happens when someone leaves for the day. I asked Colin and Eric about the origins of this but they had no answers for me. It seems kind of weird, but it's also sort of a cool affirmation of camaraderie. It may just be better than the grunt I give people when they leave for the day.
At some point I found myself arguing for these lines of Ruby today:
return false unless coupon = Coupon.find_by_token(session[:coupon_token])
return coupon.active?
Instead of a 5-6 lines of if/else code. Have I become the very person I despised when I got into Ruby? That guy who can't rest until lines of code have been reduced to unreadable terseness? Even inject doesn't look so bad to me anymore...
Of course, if we were using a current version of Rails we could do this:
!!Coupon.find_by_token(session[:coupon_token]).try(:active?)
Now that's teh hotness.
Comments
With that said, I'd probably write that code like so:
(coupon = Coupon.find_by_token(session[:coupon_token])) && coupon.active? || false
How about monkeypatching Object, Boolean and NilClass to add a #to_boolean method? (expression...).to_boolean probably makes more sense than !!(expression...)
There is something really invigorating about coming into an office, and, before you do anything else, you walk around and shake everyone's hand.
Some hate it. I use it sparingly.