Always Get Better

Archive for February, 2010

CSS Sanity: Remember Best Practices When Using New Tools

Monday, February 15th, 2010

Now that the rebellion against IE6 has hit mainstream, a brave new world of CSS3 and HTML5 has been opened to web professionals.

Beware Mixing Purposes
CSS is intended to define the appearance of elements, not their behaviour. Be very careful about “overloading” CSS to accomplish tasks best performed by JavaScript.

A popular example of poor CSS usage is drop-down menu lists. Some web programmers use CSS’ :hover selector to instruct the web browser to display sub-navigation when the user hovers over a list item.

ul#menu li:hover ul { display: block; }

This is much better accomplished using a touch of jQuery:

jQuery("ul#menu ul").css({display: "none"}); // For Opera
jQuery("ul#menu li").hover(function(){
jQuery(this).find('ul:first').css({visibility: "visible", display: "none"}).show(268);
},function(){
jQuery(this).find('ul:first').css({visibility: "hidden"});
});

Not only is this example less dependent on consistent web browser support for the CSS :hover selector, we’ve even thrown in a spiffy little roll-out animation.

Keep It Simple
The nth-child selector is one that stands to be abused by overzealous developers. Imagine this: change the display of every nth element as defined through an algebraic expression.

Why is this a bad thing? CSS is run in the same memory space as the general web page – that’s why it’s so fast. JavaScript tends to be isolated; meaning if you make an infinite loop in JavaScript, the web browser will eventually stop it from running. If the same thing happens in CSS, your web session is probably toast.

Separate Logic from Presentation
CSS was a leap forward because it separated presentation from structure; rather than programming font and colour elements, designers were able to explicitly control the way their web page appeared on screen. HTML was being used to serve the purpose CSS was designed to cover.

More recently, CSS has become a crutch to enable functionality better suited for JavaScript. When unsure about which to use, ask yourself: Does this solution affect only the display, or is some action happening?

iTunes – The Future, or Just a Toy?

Saturday, February 6th, 2010

Following iTunes’ development has been an interesting experience. We’re moving toward a world in which physical packages of music is a thing of a past; in the meantime we’re stuck with a middling service.

My complaint goes something like this:

My wife recorded Grey’s Anatomy; when she was watching her tape the next day, she was surprised to find advertisements telling her the story from her episode was being continued in a crossover Private Practice on a different channel. Oops.

So I went on iTunes and bought her the episode she missed. $3.50 is pretty steep for a 40 minute TV show but that’s the price you pay for the convenience. After enjoying the program, my wife decided she wanted to see the rest of the season – so I bought that for her too.

When you buy a season of TV, iTunes warns you that any previously purchased episode will be downloaded again – essentially you’d be paying for it again. I can handle that – it makes sense that an item would be sold individually and part as a collection.

Two problems (both stemming from me not digging deep enough into the literature, but also totally unreasonable):
1. When I was billed for the season, I was billed individually for every episode, at the full $3.50 rate. So there was no reason to double-bill me for the episode I’d already purchased since the billing wasn’t based on a ‘full season’ – why is the system unable to correlate previous purchases and prevent the double-purchase?

2. I thought I was buying a whole season of the show – in fact I only bought the episodes that had already been released. A “Season Pass” (pay for the season and new episodes download as they become available) is something completely different… it would have been nice to have been informed of the difference.

$42 is a lot of money to pay for 11 episodes of TV. I don’t think I’ll be dropping a lot of money into iTunes when I can pay half that amount for a full season on DVD – not to mention get the benefits of hard copy, physical media.

My verdict: iTunes is an interesting model and was a fun experiment for us, but not at all cost effective. Bandwidth can be expensive, but the cost of distributing digital media is essentially $0. I would have thought TV episodes could be sold for less than $1 and still make a healthy profit for the content creators (no manufacturing costs, no distribution, no retail partners — Apple takes a cut and the rest is pure profit). What can I say, I was the one who got suckered into paying double the price for half the product.