It’s freaking cold in Calgary

Minus 34. Celsius. (Not that it would matter much more if it were Fahrenheit.) That’s 14 degrees below my thermal underwear threshold (that would be when I put them on). That’s what it was on my way to work this morning.

What the hell is going on around here?

Calgary has been in the grips of a deep freeze since about the beginning of the year. My longjohns haven’t seen the drawer for weeks. Going outside is a serious consideration, namely, how many layers to wear? One of my co-workers (Scott) has been wearing googles to prevent his eyes from freezing.

This makes the pain in my left shoulder all the more poignant. What’s it from? Injections. Specifically, vaccines for Hepatitus A, B, and a tetanus booster. All of these I got last night at the Bowmont Travel Clinic.

Why? Because next Wednesday morning, at 06:45, Alex and I will be winging our way down to sunny (and considerably warmer) Costa Rica.

I haven’t been any place warm since 1996 (when I did a trip around the southwestern United States with my friends — see [[Road Trip of the Southwest United States]]), and I haven’t been south of the United States since about Grade 10 or 11 (when my family went to Akumal, Mexico). I’ve never been to Costa Rica, and I’ve heard nothing but good things about it. Frankly, it sounds like a lot of fun.

We’re starting off in the capital, San Jose. We’ll be there for two nights before heading out to Arenal, noted for the Arenal Volcano, the most active in Latin America. (Relax, it’s not a pyroclastic volcano, like Mount. St. Helens or Mt. Soufriere in Monserratt — it’s more like Kilauea in Hawaii.) We’ll be there two nights before heading out to the Pacific coast and Tamarindo. We’ll be there for four days, one of which will be Alex’s birthday (which is the reason we’re going there in the first place — she wanted to be on a beach in January … and who am I to refuse?). Then we’re back to San Jose for one more night before flying out.

All of this brings me back to the injections. You’ve no doubt seen that commercial of that tasty-looking tropical drink where the narrator tells you about the Hepatitus A in the ice cubes? Latin America, even Costa Rica — which is by far the healthiest of all the Latin American countries — have high Hepatitus risks. Alex is already up to date with her shots, so it was my turn to get a couple pricks.

All three of them.

Why three? Well, when I talked with the clinic doctor (a requirement — you can get the shots with a meeting), she informed me that I had to get separate A and B shots (I was too late to get Twinrix before leaving), and while going through the list of things I should receive, she also suggested that I update my tetanus, which is a couple decades out of date. (You know you haven’t seen a doctor in a long time when…)

I hate needles. Really hate them. But I seem to hate them less now than I used to. It’s probably the flu shots that I get that help me. The more shots I get, the less I seem to hate them.

Except for Hep A. When the nurse was injecting me, I couldn’t help but notice the fact that she wasn’t stopping. For a moment, I thought that she’d accidentally hooked me into a garden hose and was flooding my arm. Turns out that the Hep A shot is a full millilitre. Doesn’t sound like much, right? That’s quite a lot more than the average. And it HURTS. I actually felt nauseated. (Not that it takes much for me and needles.)

One down, two to go. I had to breathe a few moments before getting the next two.

They were smaller, and went in quick succession. I hopped off the table and had to almost put my head between my legs to let the colour flow back to my head again. I have no idea why on earth needles make me feel this way. I hate that.

The nurse warned me that my shoulder might hurt the next day. “The NEXT day? It hurts right now!”

So this morning, I wake up to -34 degree weather. My shoulder is just shy of severe agony. I can’t raise it. It’s a dull ache that won’t go away. I can’t even lift a can of pop without flinching. Putting on my jackets (outer jacket with a fleece jacket for extra protection) is an ordeal.

But I just keep telling myself: There’s a beach in this.

JavaScript Web Standards

I’ve been getting this question from my colleagues lately, and I think it’s a valid one to ask. The fact that it’s being asked shows that people are thinking about best practices and how to best meet the needs. However, the fact that it’s being asked also shows that people really don’t understand a fundamental principle of web standards.

How do web standards and Javascript get along? How do you employ Javascript that is web standards-compliant? It’s a tough question, and so far, I haven’t come across a clear answer.

A properly-developed, web standards-compliant site (or even just a page) should have separation: content, presentation, structure, and function. A quick recap on those: content is the important information on a page (primarily text and images), presentation is how that content should appear to the user, structure is the HTML that defines the various parts of the page that the content falls into, and function (or more specifically, functionality) is the browser scripting that drives some of the interactive features on a site.

The first major break was between content and presentation. Then came structure. These were culiminated with the creation of the CSS Zen Garden. Given, the textual content is baked into the Garden’s code, and the separation between presentation and structure is trivial. (As a side note, the marriage of the items is just as important as the separation.) This was great stuff. And even though the Garden’s been around a few years, now, the movement is just getting to the fourth and final piece: function.

And make no mistake, folks, this storm is coming.

But what does this mean for you, the developer? Thankfully, it’s not too complicated, at least from a comprehension perspective. Implementing? Well, that’s another issue.

Under the idea of separation for web standards, Javascript should be separated from the page upon which it acts. This means no in-page Javascript, including onclick, onmouseover, onload, or other such event-driven methods. Code is placed into one or more external files, which are then loaded by the browser. This is the same way presentation is/should be applied to each page.

Naturally, this is a little worrisome to developers, since many of us have become very dependent on having that functionality. If we don’t have those methods in-line, how do we control the functionality? We’re used to slapping in an onclick event on <a href> tags to solve our click event patterns. Never mind the countless onmouseover/onmouseout events we use for effects.

Introduce self-awareness. At least insofar as Javascript methods can be self-aware, anyway. Instead of HTML elements having code to handle the event, a Javascript loaded through the onload event finds HTML elements through the Document Object Model (DOM) and inserts the appropriate handlers into the various elements. It’s transparent to the user, and a Javascript developer can modify method behaviours without ever touching the HTML structure.

Loading up the onload event, however, is not a wise idea. Not only is it ugly, eventually the call will become so long that you won’t be able to maintain it. Introduce the onload handler. With a simple piece of code, you can set up a method stack that calls other Javascript methods. The methods are popped and pushed as needed, defined by a controlling function or static list. A very simple version — an array — would look like this:

function onloadEvents() {
  for(var i=0; i<loadarray .length;i++) {

Very simple, very crude, but it works. (Too many evals can slow down a script dramatically, so don’t get carried away.) Events are added to the onload handler through array declarations:

loadArray[loadArray.length] = "functionName()";

A smarter script creates an object list of items, calling them in turn.

I know what you’re thinking: that’s a lot of extra work. It is, and it isn’t. It is because you have to think about how your page is built, and how functions would recognize the patterns needed to build your events. For example, if you’re using a structure for menus or have a specific classname for a link, then it’s not so bad. You create a method that can initialize that structure, applying whatever functionality is needed for the specific purpose. It’s run just once, and provided the method isn’t too complicated, runs quickly.

Where additional work comes into place is the need to build the initialization methods and set up an onload handler (such as above). Once it’s done, though, the rest should be relatively easy.

This is all in theory, and is something that I think about a lot. There’s a lot of “what-ifs” to consider. My personal favourite is: What if this is a one-off situation? Do I spend the time and code to build a one-off onload handler? This is the one I usually end up stumping myself on.

In CSS, one-offs aren’t such a big deal. You create a single class, set up the formatting, and let the browser apply it as needed. But Javascript doesn’t apply automatically. It needs to attach itself, not unlike a leech (just not so bloody). And that’s where you can get caught. Do you take the side of lighter Javascript files and run the method in the HTML, thus defeating the idea of separation? Or do you follow the perceived standard and risk code bloat?

It’s a question I keep asking, and so far, I’ve yet to find an answer. The zen of Javascript and web standards is coming. The question is: who will find the inner peace first?

2004, A Year in Review

2004 wasn’t exactly what I’d call a tumultuous year, but it was certainly marked with some pretty big events for me, not the least of which was meeting Alex. If there was a number one in the list, she would be it. 2005 is already looking to be an interesting year, since there are a lot of things that will be happening for me. It’s not going to be an easy year, but if we always had easy years, we’d never feel a sense of accomplishment.

Continue reading “2004, A Year in Review”

New Years Eve in Calgary

It’s an interesting start to the year, to say the least.

Alex and I spent the holidays partly apart. As such, we ended up having Christmas Eve on New Year’s Eve. To make it interesting (as if being together wasn’t interesting enough), Alex pulled a scavenger hunt on me, sending me around her condo trying to find the various presents she’d stashed. Each had a clue to the following present. I can amount it either to my extreme intellect [insert derisive laughter here] or to the obviousness of the clues [Alex knows her audience, to say the least], I managed to find them all without being stumped.

The let down wasn’t in the presents, but in the crappy countdowns. We just couldn’t get interested in them, and it’s really lame to be watching the Times Square countdown when it happened two hours earlier. And out here, it’s -41 with the windchill, so going outside really isn’t an option for us.

That’s probably why we slept in on New Year’s Day. I forced Alex to stay in bed while I made breakfast. But I couldn’t keep her in bed forever, especially when there’s a 20x rewards sale on at Shoppers Drug Mart. It was a 10-block walk in -21 degree weather (not counting the wind chill). Warming up actually hurt. But for 20x points, I’m sure Alex would go through pretty much anything. The hot chocolate at Second Cup made the walk back considerably easier.

The big things that happened over the holidays: Wedding planning. And yes, that also means something else obvious: Engagement. (Yes, I know you saw it coming.) This time, I know it’s right.

The funny part is, we started planning for a wedding before we were even actually engaged. We goofed around with a huge number of ideas, including theming it ala Monty Python. We were going to recreate parts of Monty Python and the Holy Grail to keep it interesting and humourous. Whether or not we stick to this come August remains to be seen, of course. Funny as it is, I have my doubts that we’ll actually do it.

A stop at Michael’s over in Westhills supplied paper, ribbon, and various crafts to make invitations. Alex is far more craft-oriented than I am, and wants to make the invitations. (I’d just as soon whip them up on a computer and have them mass produced.) We started working on prototypes at Alex’s later in the afternoon.

This is when the Big Event happened. When I was back home, I picked up the engagement ring. It was Mom’s, and my grandmother’s before that. It’s a Sowrey heirloom now, and something I wanted to pass to Alex. A bit of a risk, mind you, since Alex had certain expectations in mind for what she wanted, and I was about to deliver something she hadn’t previously considered.

As I was tying a ribbon into one of the prototypes, the idea hit me. I had the ring in my pocket. While not the most romantic place to conduct this, it was private (which I was sure Alex would prefer) and related directly to what we were doing. A snap decision, in other words. Tying it in was difficult, but when it was finally attached, I held the card up to show her, and said:

What do you think?

She was a little stunned, mostly because I think at first she didn’t really see the ring, and then had to contemplate how the heck I’d gotten a ring without her knowing, followed by having to accept that she was getting it without expectation and that it was decidedly different than she had wanted.

I had wanted to do this for her birthday later in the month, when we go to Costa Rica. But Alex told me two things: 1) she wanted to tell her friends at a Stitch ‘n Bitch before we left, and that 2) she liked her birthdays to be special and without complication. In other words, she didn’t want to get engaged on the same day. How’s that for putting a wrench in plans?

When Alex finally realized what it was, I looked at her and said:

Only one catch: It comes with me.

Yeah, that’s me, Mr. Romantic…

We ate dinner together and celebrated with wine. But I had to go home afterwards to prepare for the next evolution in my job. I’m down a strong developer and need to backfill, and Cory’s shift to client services means I’m now the Web Development Practice Lead.

It’s going to be an interesting year…