migration to squarespace

I'm in the process of moving from and blogger to Please let me know if you run into any broken links or mis-placed apostrophes. You know how I hate those. 


Java foreach loops on empty collections

I've been worrying about whether I need to check for null when invoking a foreach loop on a collection that might be empty. The answer is, nope, I don't need to check for an empty list; java just Does The Right Thing.

List<Object> list = new ArrayList<Object>();"here's a list that was always empty: " + list.toString());
for (Object o: list) {"here's an object: " + o.toString());

...yields this output:
INFO: here's a list that was always empty: []
INFO: done

These alternate ways of expressing the same loop also all execute without a problem, even for an empty list:

for (int i = 0; i < list.size(); i++) {
Object o = list.get(i);"here's an object: " + o.toString());
for (int i = 0; i < list.size(); i++) {
Object o = list.get(i);"here's an object: " + o.toString());

That's just a detail that's been bugging me, and now I understand the behavior. For what it's worth, I couldn't find this issue addressed in the JSR.


best of ben


graphical diff for git on mac os x

I just configured git to use FileMerge for diffs. FileMerge is a pretty graphical diff tool. I couldn't find quite the right invocation via google, so here's what I did:

  1. Create ~/bin/ with these contents:
    /usr/bin/opendiff "$2" "$5"

  2. Make it executable
    chmod ugo+x ~/bin/

  3. Make git use this little script for diffs. Edit ~/.gitconfig to include these lines:
    external = "/Users/ben/bin/"

Now the next time that you call git diff HEAD FileMerge will open. GUI sweetness.


missing out on flex?

Last week I finally started using an AIR application, TweetDeck, because my brother said it was cool. Now I'm reading about Flex and AIR, and I have to say, I might have been missing out on a good thing. It looks to me like Flex and AIR are together a powerful front-end platform for building nice applications... where by nice I mean the things that Ben Shine traditionally loves: smooth, swoopy, delicate, rounded, subtle, surprising, shiny.
This bears investigation.