dmuth's blog

Node.js 101: Flow Control

"I eat, sleep, and breathe PHP (or C++). How is flow control different in node.js?

The if/then/else constructs that you're used to aren't any different in node.js, but function calls are much much different. Take this code, for example:

var results = db.query(query);
console.log(results);

This won't do what you'd expect. The results variable will very likely be null. This is because nearly every function call in node.js that involves I/O, whether it's to the network or the filesystem takes a callback function as an argument, a function which will be executed only upon completion of the request. This is due to node.js's asynchronous nature.

Taking the above example, you'd write something like this, instead:

db.query(query, function(error, results) {
   if (!error) {
      console.log(results);
   }
});
console.log("Sent our query!");
3.088235
Average: 3.1 (68 votes)
Your rating: None

Older Stuff

More buckled roadway
Under construction. Permanently.

I created this page to house links to older stuff that I don't necessarily want in the main menu, but would like have one click away from it...

3.666665
Average: 3.7 (3 votes)
Your rating: None

Node.js 101: Error Handling

"Why handle errors?"

Because as a programmer, catching errors is part of your job. You need to know when a disk write fails, a database query times out, or a web service returns zero bytes. You need to be able to react to exceptional (and not-so-exceptional) conditions, and do The Right Thing, even if The Right Thing is merely to print out that error and exit.

"I can just throw an exception, right?"

In some languages, this might work. In Node.js, not so much. Remember, each time a callback is executed, it gets its own stack. Take this code, for example:

function f2() {
    setTimeout(function() {
        throw new Error("I AM ERROR.");
    }, 100);
}

function f1() {
    f2();
}

f1();

Execute that, and here's the stack trace you'll get:

timers.js:96
            if (!process.listeners('uncaughtException').length) throw e;
                                                                      ^
Error: I AM ERROR
    at Object._onTimeout (/Users/doug/tmp/node.js/stack.js:6:9)
    at Timer.ontimeout (timers.js:94:19)
3.357145
Average: 3.4 (14 votes)
Your rating: None

My thoughts on "Microsoft's Lost Decade"

Our newest feature in Windows: Space Crabs!
"Our newest feature in Windows: Space Crabs!"

There's an article making the rounds called Microsoft's Lost Decade. It's a good read. I wanted to share a few of my own thoughts on it, based on my time in the software industry.

At the center of the cultural problems was a management system called “stack ranking.” Every current and former Microsoft employee I interviewed—every one—cited stack ranking as the most destructive process inside of Microsoft, something that drove out untold numbers of employees. The system—also referred to as “the performance model,” “the bell curve,” or just “the employee review”—has, with certain variations over the years, worked like this: every unit was forced to declare a certain percentage of employees as top performers, then good performers, then average, then below average, then poor.

From my perspective, this is a really bad idea. Using Microsoft's ranking system, if you're a rockstar programmer who is working in a department with other rockstar programmers, if you find yourself lacking in skills or productivity by even the slightest bit compared to your peers--but well above that of an "average" programmer--your performance would be classified as "below average" or "poor" under the system, you would lose your job, and Microsoft would be out one rockstar programmer. (If you're been paying attention, Intel has/had this problem, too!)

Contrast this model of employee ranking with the system used at Symantec when I worked there. Each employee was evaluated in a number of areas and received a rating from 1 (poor) to 5 (excellent). To the best of my knowledge, there were no forced percentages or anything like that. Each employee was honestly evaluated based on their performance and received feedback on how to do their job better. I consider this method much saner than being rated as "poor" simply because one weren't quite as good as their peers.

Microsoft's ranking system led to some pretty horrific things:

3.416665
Average: 3.4 (12 votes)
Your rating: None

Doug's Anthrocon 2012 Wrapup

Anthrocon 2012 has come and gone, and I've only recovered enough just now to actually write about it and share my pictures!

First, how about some numbers:

  • Attendance: 5,179 attendees
  • Number of fursuits in the Fursuit Parade: 1,044 fursuiters
  • Money raised for Hello Bully: $20,656
  • Number of artists in Artists' Alley: 212 artists

All of these numbers are records, way above and beyond anything we've had in previous years.  It was epic!

As usual, we had our share of of outside media coverage [1] [2] [3] That's perfectly fine however. We were in the middle of downtown Pittsburgh, after all.

Snickerdoodle and Flow Kitty

From an Operations standpoint, the con went pretty darn good this year!  Ops went well, and onsite registration went well.  Even the badge printers behaved themselves this year!  The only noteworthy issue we had to deal with was our Nexttels.  Seems that our vendor didn't bother to tell us that they wouldn't actually work in Pittsburgh.  This caused us some issues with communication, but wasn't insurmountable, just annoying.

All Cheetahs Look Alike Bierzun Wii Raver and Nyancat

Kane Husky Clementine and Boyfroend Flash Adalwolf and Shadow Destroyer

Other than that, the con was pretty much a blur for me this year.  Things went as they should have, and I mostly stayed out of the way of my hard working Ops Staff and let them do their thing.  With this growth in attendance, however, I have started making plans for staff positions and such to handle even more growth next year.

Oh, I got to see Sardyuon's Encore Performance.  The man is amazing:

Sardyuon Balancing On Chairs Sardyuon Balancing On Chairs Sardyuon Balancing On Chairs

And this is what 1,044 fursuiters look like:

Lucario The Husky Fursuit Parade Lineup Fursuit Parade Lineup

Actually, that's not entirely accurate. There is a huge group shot over here.

Say... did you know that not everybody at Anthrocon wears a fursuit? I have proof!

Anthrocon's Board of Directors and Guests

Do you want to see my full archive of pictures from Anthrocon? You can find them over over here.

Next year's Anthrocon will again be held in Pittsburgh from July 4th to 7th, 2013, and the theme will be "The Fast And The Furrious". We'll see you there!

3.42857
Average: 3.4 (14 votes)
Your rating: None

Conventions I Will Be Attending

Fursuit Parade
The fursuit parade from Anthrocon 2008

Since I keep getting asked which conventions (furry, and otherwise) I'll be attending, I decided to put up a list: