Monday, June 25, 2007

Foolproof content assist for for-each

I recently figured out a strategy for guaranteeing that the Eclipse Java editor will infer the correct local variable while filling in one of the 'for' templates (for-each, for-each array, et cetera.) If it feels complicated, it's possibly because the refactoring keystrokes just aren't ingrained in your brain and your fingers.

After using the for- templates for a while you can get a feel for when Eclipse is likely to properly infer which variable over which you want to iterate. If it doesn't you can give it a great hint:

e.g.

List list = ... Map map = ... foreach{cursor}

{cursor} represents the cursor. Pressing ctrl-space, what will it infer?

The trick is to make it terribly obvious which variable you want foreach to choose for its completion. For instance, supplying a no-op statement that references an iterable object like this:
List list = ... Map<K,V> map = ... list; foreach{cursor}

will complete as
for (String string : list) { }

You can do really nice things with this like:
List list = ... Map<K,V> map = ... map.values(); foreach{cursor}

Now this doesn't *quite* infer correctly, so use Extract Local Variable (Ctrl-Shift-L) to make map.values a local variable:
List list = ...
Map map = ...

Collection values = map.values();
foreach{cursor}

which gets you
Collection values = map.values();
for (Integer integer : values) {
}

After that, use the Inline refactoring tool to inline the temporary variables.
for (Integer integer : map.values()) { }

Whee! Extract Local Variable and Inline are your friends.

Saturday, June 23, 2007

Rigatoni with Sausage

I lived in New Jersey for ten years, and I miss it terribly. I spent most of that time playing Ultimate Frisbee with a team that played (and still plays) in Brookdale Park. I spent eight years in Morristown and the last two were in Montclair, just a couple of miles from the park. About half a mile from the park are two locally famous ice cream parlors.

Applegate Farms not only makes fantastic ice cream, but they create a memorable family experience by serving outdoors barn-style (this also means attending their shop is slightly less attractive during winter.) They specialize in ice cream and other deserts, all of which are top-notch.

Holsten's, which is now absurdly famous, is an indoor parlor that also sells candy and has a lunch menu. I wouldn't necessarily go there just for ice cream, but if everyone wanted a meal followed by a sundae, this would be a great place to go.

There are other fantastic local ice cream shops without leaving Holstens' street (Broad Street). There's an unreal Gelato place (sadly I cannot find its name), and yet another fantastic and unassuming homemade ice cream shop called Magic Fountain next to the (ought to be) world-famous Nevada Diner.

None of this is really my point. I'm not trying to talk about ice cream and I'm not going to bring up the restaurants (but oh, how I pine for a dinner at Miele's in Verona, or absolutely anything from Casa Turano.)

My point is that baristanet posted a story where they interviewed the owners and employees of Holsten's about their newfound fame, and when I hear the young waitress speak in what I'll classify as the "Italian North Jersey" accent, all I want is to go home. That's my point. It was that, more than the video of my old neighborhood, more than the thought of satisfying my taste buds. It was the sound of their voices.

Now you will understand: one of the best parts of Miele's, besides the food (sigh), is my memory of the waitress asking "OK, who had the rigatoni with sausage?"

Friday, June 15, 2007

Maggie's Third and Fourth Day

Now before you go off thinking, "Will there be a post about days 5, 6, 7 and so on?" I promise you the answer is 'no.' But I think it's important to talk about the developmental changes in Maggie.

Maggie's third day was a much easier one. She started relaxing, and we did too. Every day, Maggie and I play tug-of-war. You can tell much about her temper these last days from tug-of-war. The first day she was frenetic, the second day she was going through the motions. Yesterday and today she was really enjoying herself. It's a good thing, this tug-of-war, because she's clearly a hunting dog, and I like knowing that there won't be an unresolved tension. She's been crapped-out tired every day, which suggests we're running her well.

Last night she came back up to the bedroom to sleep next to our bed.

As for being in the office, it seems to work OK. People love stopping by to visit Maggie. I think she is having trouble trying to find her place in the small room. I take her out, but not too much. I I'm sure she would like more space. (So would I!) We also need some decent toys and more of a cave-like space for the office. Basically, it seems to be working well.

Some other strange facts:
  • She doesn't like peanut butter, watermelon, or pizza crust, but she liked mildly roasted potatoes.
  • On the other hand, she loved the cookies my coworker Alison made. Peanut butter, milk and flour.
  • She won't eat hard treats or dry dog food (though we can mix dry dog food with a little canned food and she gobbles it up.) Someone suggested she may have dental issues. Then again, yesterday we thought she might have osteoporosis in her hind legs, but she sits just fine.
  • She doesn't mind if we leave for fifteen minutes or so, but...
  • She likes to bark a little more than we like. It's protective barking, which I can appreciate, but we would like to cut that off.

Today was the first day, when I came home, she wagged so much her butt shook. Yes-sirree, things are looking up.

Wednesday, June 13, 2007

Welcome, Maggie!

In big family news, we got a dog! She's a beautiful 8-year old named Maggie. We were told she's a Cairn terrier mix, but I'm also told that Cairn terriers tend to be much lighter than Maggie (who weighs in at 40 pounds.)

She's doing great. She's healthy (upon visual inspection). We still need to take her to a vet for a check-up.

Yesterday we had a very busy day. I picked her up at 10AM from the animal shelter and brought her home. She was so happy to be out of the shelter, and so excited to be in a home! She found the things that were her toys and scattered them all over the room. Then she ran up and down the stairs about 30 times.

I took her on several long walks around the neighborhood, including a visit to my office, which I would like her to feel comfortable with as soon as possible.

All day yesterday she wouldn't be anywhere that we weren't. If we moved from one room to another, she came with us. She slept at the foot of our bed, on the mattress made just for her.

Today, I took her to work with me once more, for a longer period of time. I practiced leaving her alone. The first time I left her was for 10 seconds. I stayed behind the door. She seemed fine, but a little scared. The second time, I left for 5 minutes, and when I returned, she was hiding in the corner. The third time, I left for one minute, and she seemed just fine. Beth picked her up at 11. By the time I got home, she was exhausted. She gobbled down her dinner, lied down, and went right to sleep. She hardly wagged her tail all day, and she slept as far away from us as she could, on the first floor by the front door. I wish she'd get up off the cold floor! Silly dog.

I think the first day, she was all caught up in the excitement of someplace new, and being out of the animal shelter, wanting to learn what was going on, and was afraid of being alone again. Today I think she is starting to realize that her home is new, and that her new family has foreign expectations.

These two days have been really exciting but also quite exhausting, but we're happy to have her in our lives.

Pictures coming soon.

Friday, June 08, 2007

How to get ahead in business

My first job after college was for a company that refused to give me business cards. I met clients often enough during my three years that I was starting to get embarrassed when I had to write my phone number on a piece of paper. I argued that the cost for business cards was worthwhile even if I paid for them myself (the cost being twenty dollars.) My presumption was that I could take half the business cards, spread them around all the local restaurants in their "drop your business card here and win a free lunch" fishbowls, and the cost would pay for itself.

Incidentally, have you ever wondered why they make fishbowls out of flimsy plastic? What kind of fish would be able to live in one of those things?

Sorry, I went off-topic. Without approval, I filled out the paperwork requesting business cards and submitted it for my director to sign, along with a note asking him how I should pay for them. I guess my director didn't feel like fighting with me any more, since he approved the order, without ever asking me to pay the twenty dollars. After scattering about a twenty cards in local eateries, I gave my resignation. Two days before I left, I got a call from my favorite local restaurant: my business card was selected among the dozen or so in the plastic fishbowl. That was the best free lunch I ever had.

The moral of the story: Always fight with your director. It may get you something for free!