Posts categorized “Uncategorized”.

Thrown for a loop by JavaScript’s ReferenceError

The other day I was talking to a couple of friends about a ReferenceError they were getting in some code they were running. They were just checking for the existence of a global variable. They were just doing this:

   if(foo){
      doSomething();
   }

Would you expect that to work? If so, you’re better at this than I am. If foo is not defined, either in the current scope or globally, you’ll get a ReferenceError there. Why does this strike me as so inconsistent? Consider the following:

   var foo = {};
   if(foo.propertyThatDoesntExist){
      doSomething();
   }

If you check for the existence of a property of an object that doesn’t exist, it simply returns undefined. No error is thrown, your code doesn’t halt execution, things don’t explode. In fact, the interpreter will work its way up the scope chain from foo, looking for the missing property.

Now, consider this example:

   var setImplicitGlobal = function(){
      implicitGlobal = 'Are you sure this is what you wanted?';
   }

   setImplicitGlobal();
   alert(implicitGlobal);   // Alerts the string from above

So when we’re doing assignment and try to assign a value to an undefined variable, the interpreter assumes we wanted a new global variable and creates it for us. Despite the fact that this is almost never what anyone would reasonably want to happen.

Finally, consider the following:

if(foo){   // Reference error when foo has not been declared
   doSomething();
}

if(window.foo){  // Undefined when foo window.foo has not been set.
   doSomething()
}

So when we try to assign a value to an undeclared variable, the interpreter assumes we meant window.foo and creates it for us. But when we’re trying to read the same thing, it doesn’t make the same assumption, throws an error, and breaks our script even when we thought we were coding defensively.

What am I missing here? This is sort of inconsistent, is it not?

The most astonishingly bad product I have ever seen

Sorry for the non-UI/non-software post, but I happened upon Dr. McGillicuddy’s website today (don’t ask me how, it’s a long story) and from there found my way to the General Store, where people who survive the awful site design and navigation can buy various merch branded with their favorite budget liqueur. It was there in the Drink In Style section that I found this:

The incredibly awful Dr. Family Ski Shot

The bafflingly awful Dr. Family Ski Shot

It’s the Dr. Family Ski Shot. I guess it’s for the family that drinks together? Or it’s a ski shot designed by Dr. Family? Either way, it’s $59.99. For that kind of scratch, it had better be pretty useful, no? So what would you say it is…you do here, Dr. Family Ski Shot?

From the site:

Line up for shots. The Doctor Shot Ski is designed to let 3 people stand side by side to do a shot. It looks and feels like a real mini ski.

So it’s designed to let 3 people stand side by side to do a shot. Were people having trouble doing that without a schnapps-themed piece of miniaturized sporting equipment?

I am glad to see that it looks and feels like a real mini ski. I was getting really tired of all those drinking aids that didn’t feel like a mini ski. Or look like a mini ski. This one nails that, because, well, it was designed to.

Thanks, Doc!

Not pissing users off is pretty important.

Sometimes it occurs to me that I’m putting up with unreasonable pain from the software I use on a day-to-day basis. It’s really easy to get into habits and put up with some pretty big deficiencies.

I think it’s dangerous allowing users to put up with annoyances. You’re basically training them to dislike and resent your software and pushing them to find a replacement. Just getting the job done is not nearly good enough.

I will not allow this to happen with Mockery. I’ve got the UserVoice page set up. I’m on top of support emails. The rest of this is just a process of making sure that users communicate any issues to me and making sure there aren’t any annoyances just minor enough for people to work around them.

The Red Sox are dead. Long live the Red Sox.

Tough day here in Red Sox Nation. I think just about everybody had the impression that this year’s team didn’t have what it was going to take, but most of us were hoping for more than this and a rematch with the Yankees in the ALCS would have been fun.

I am looking forward to having more time on my hands to work on some exciting new Mockery enhancements. The Celtics look great this year, and I’m going to enjoy following them. Nevertheless, it’s hard not to be a little melancholy after the long, tough baseball season just ends with a thud.

For what it’s worth, I’ve been saying that the Sox need to either make Papelbon a starter or trade him while he has peak value. Daniel Bard is my favorite player to watch right now and I’m confident that if he had been the closer we’d be getting ready for tomorrow night’s game. Maybe this will be the push that the front office needs.

I’m pretty excited about Google Wave.

The more I hear about Google Wave, the more I like the idea. It’s a collaborative environment that Google describes as equal parts conversation and document, which is interesting to me for a lot of reasons.

For one, I really love IM. I just really started using it for real this year, but I really prefer it to the phone. Wave expands upon IM with a lot more interactivity, but also with an API that can be used to build functionality on top of Wave.

What I’m hoping is that it will be possible embed the chat-like portions of Wave into existing app and use the “roll-back” and live updates to facilitate collaborative editing. I would love to add it to Mockery.