Local Variable Names: Whole Words Versus Letters

I’m trying to make sure I really understand Ruby’s blocks and closures, so I was digging ahead to Chapter 22 of the Pickaxe book on ‘Blocks, Closures, and Proc Objects.’ On page 358-359 there was a bit of example code:

def meth1
  (1..10).each do |val|
    return val  # returns from method
  end
end

I would have just used

1
value

for the variable name, but maybe this is a very popular idiom in Ruby.

t = Thread.new do

OK, this is the sort of stuff that drives me crazy in Java when people do it. Instead of just naming it thread or something logical we just assign it to

1
t

, a meaningless English character. When you read later down in the code you get no hint about what

1
t

is so you have to hold that in your brain or refer back to its definition again.

Then there’s there’s these examples :

pr = Proc.new { next 99 }
p = Proc.new { return 99 }

Couldn’t it have been at least

1
proc

! At this point I don’t grok enough about ruby’s Proc class to really come up with a better name, but it appears to be a closure so that might be a reasonable name as well.

I know the counter arguments. One, this is a book with example code so they’re trying to save space. Possible, but you’re also introducing the language to people so you should probably try to be as clear as possible. Two, it saves typing. True, but typing is not what slows down my coding, defects and harder to follow code does. Three, that’s the Ruby idiom. That may be very true, so this may seem as normal to me as using i,j for looping counters. I’ll just have to see if that proves out.

Technorati Tags:

,

Mini-Review: Aardvark’d: 12 Weeks With Geeks

Short take, a really good concept, but not that great a documentary. You can find longer reviews here and here. I really appreciate Joel’s attempt at producing a documentary on Fog Creek Software’s internship program. The only problem would be a narrative never really develops beyond time passing over the 12 weeks and the growth of a tomato plant.

You do get the feel of a small startup, and you get to see the nice private offices (but not for the interns) and dual monitors + Aeron chairs for everyone. I did think seeing the interns negotiate for the domain name was funny. There was almost no actual negotiation. The first price from the owner of copilot.com was 20k. The interns decide the most they want to pay is 10k, and they end up paying 10k because the owner claims there are ‘other bidders’. Don’t know the details, but it barely seemed like a negotiation.

I did like the quote from one of the interns on Coldfusion:

“I’m not really even sure. I don’t know what Coldfusion is. Umm, some web programming thing, I guess is some kind of half real language, according to the hard core people. And it’s the best thing ever according to the Coldfusion people.”

That was pretty much my experience starting a job back in 1997 and finding out the web team did all their applications in some strange thing called PowerBuilder.

Since I saw they were showing the movie at Software Development 2006 I may see it on a big screen and see if I get more out of it. With Joel and the director there maybe there will be some good stories to go along with it.

Technorati Tags:

Trusty Projector

One of the best things I budgeted for this year was a new projector for my team. For some reason we require anyone who wants a projector to reserve one at least 24 hours in advance for a specific conference room. Maybe I don’t have a lot of patience, but I found I was constantly begging for a projector the day of a meeting and feeling guilty about it. It was really a pain.

My predecessor obviously felt about the same way as I inherited a projector when I arrived. One small issue was that it only worked on rare occasions and was out of warranty. Fixing it was possible, but easily it could be the same cost as buying a new projector.

So I budgeted for a new projector this year and had one of my developers research and buy one in October. I knew we’d get enough use out of it in my group alone to justify the cost from using it for demos to unit testing seminars. The elimination of the hassle was reason enough.

My general philosophy is to share even if some item came out of my cost center. I also think the idea of trust is really important so I just stow the projector in my old office and not under lock and key. I think the hassle of having to lock up things and have sign out procedures generally means things get a lot less use. Not too different from the idea that requiring a lot of paperwork and receipts for small expenses ends up costing the company more in tracking costs then just setting a per diem for incidental expenses.

As people have discovered I have a projector they often just stop by and ask to borrow it. I happily lend it out no paperwork involved. The projector gets a lot more use, and I generate extra goodwill by making things easier for people. Of course the obvious downside is that someone might, gasp, steal the projector. I think positive effects far outweigh the possibility of some really dishonest employee walking off with it. If your company has theft problems you generally have a much bigger issue on your hands.

Technorati Tags:

,

Nothing To Talk About In One on Ones

I’m into the second week of holding half hour one-on-one sessions with all of my folks. Today is my big day on Wednesday afternoon where I actually hold six one-on-ones from 1:00-4:00. At least half of the one-on-ones today began with the statement:

“Hmm, I really don’t have anything to talk about this time, so I don’t know what we’re going to talk about for half an hour.”

Every one of those one-on-one sessions today went the full 30 minutes and a few I had to cut off to make time for the next session. I distinctly remember this because my bladder was letting me know it could use a little restroom break, but from 1-4 today it was wall to wall one-on-ones.

This week felt a bit more laid back. People are starting to get adjusted to the style and I’m probably a bit more relaxed. So I’m beginning to see why I should have started these a long time ago.

Technorati Tags:

,