Legends of the Sun Pig : Martin Sutherland's Blog

Why each CSS property should have its own line

Wed 11.Aug.2010 22:48

Comments: 2

A few months ago, Arjan Eising (@arjaneising) tweeted a quick poll about CSS formatting:

CSS Poll: do you place your CSS properties on one line per selector (compact), or do you use one line per CSS property (expanded)?

To put it another way, expanded is:

        .monkey {
            background:#fff url(/images/monkey-bg.png) repeat-x 0 0;
            border:1px solid #fde;
            display:block;
            font-size:123.1%;
            margin:1em;
            text-transform:uppercase;
        }
    

compact is:

        .monkey {background:#fff url(/images/monkey-bg.png) repeat-x 0 0;border:1px solid #fde;display:block;font-size:123.1%;margin:1em;text-transform:uppercase;}
    

I replied:

Expanded. Compact only works if you're the only person maintaining it & don't use source control. Otherwise, it's stupid.

Now, I feel the need to defend this statement, because "stupid" is an emotive word, and it's not one I use lightly. The nicest thing a colleague has ever said about me was that I "express strong opinions without threatening to break your fingers," and calling something "stupid" is about as close to violence as I get. (Unless you get me started on RyanAir...but that's another story.)

The first thing to notice about my comment is that it's qualified: if you are the only person working on your CSS code, and you don't use source control, then fine. Knock yourself out. Write the code however you want. Use single-letter class names for all I care. (Because they're shorter and save bytes! But only lowercase single-letters because they compress better!) They key point is: you're not harming anyone else.

But: if you use source control, that shows you care about before and after and the ability to keep a history of what's going on with your code. Source control is all about changes between once version and the next, and no matter whether you are using a side-by-side or inline viewer to see the differences between two revisions, a shorter line length makes it easier to visually identify those differences.

Viewing differences becomes even more important as soon as there is more than one person working on the code, because you will be looking at the changes that other people make. The change between two revisions can often give you more information about the reason for a change than the new code can give you on its own. When it comes to maintaining a piece of software over a non-trivial lifetime, change tracking is vital to understanding both the codebase itself, and the underlying (business) requirements.

See, it's not the readability of long lines in themselves that I question (research is vague, but I'm comfortable saying that 200-character lines help no-one); I'm more concerned about the secondary problem of being able to manage and understand changes in those lines over the long term and/or in a coding environment where you're not the only contributor.

The best way to do this is to write each property on a single line. Writing single-line CSS rules harms maintainability, which is a bad thing. There is no technical reason to prefer compact CSS over expanded CSS (rule 1 applies to CSS as well as JavaScript), so the reason for writing single-line CSS is a personal preference. In my mind, it's up there with smoking.

Okay, maybe not that bad. Most CSS won't give you cancer. But I'm going to stick to my original assessment of "stupid". I won't break your fingers, but I will swear a lot while reading your code.

That said, there is an editability (as opposed to readability) argument to be made against long lines as well. This comes down to Fitts' Law: if each property is on its own separate line, when you want to hit that property with your mouse pointer, you're aiming for a much wider target than if the property is nestled somewhere in the middle of a single long line, as shown in the image below:

And if you prefer to use the keyboard, it takes fewer keystrokes to navigate and manipulate multi-line CSS than the single line versions. (Unless, of course, you use emacs, in which case there's probably already a command to insert all those border-radius properties you wanted you to add.)

Further reading:

Radio Sunpig 2009: Thicker Ice

Sat 07.Aug.2010 23:14

Comments: 0

Reading about playlists this afternoon reminded me that I still hadn't posted Radio Sunpig 2009...and it's August of 2010 already. (Nothing new there, then.) But I can honestly say that I finalized the playlist itself at the beginning of January, and the artwork shortly thereafter. I even issued a couple of prototype CDs at the end of February, but it never went to a full production run (of the usual 7 copies). Oh well.

Radio Sunpig 2009 is subtitled "Thicker Ice" because it felt like in 2009 the Sutherland household was on a more solid footing than in 2008. It still had plenty of ups and downs, but the ups were upper and the downs were less down. A good foundation for 2010. And musically, it saw me start going out to live gigs again. Which is awesome. And any year in which I can get to see the Tragically Hip twice in the space of a single week has got a hell of a lot going for it.

  1. Battles - Atlas
  2. Fight Like Apes - Tie Me Up With Jackets
  3. Frightened Rabbit - The Greys
  4. Phoenix - 1901
  5. Apes & Androids - Nights Of The Week
  6. School Of Seven Bells - Half Asleep
  7. The Heavy - How You Like Me Now?
  8. Deastro - Daniel Johnson Was Stabbed In The Heart With The Moondagger
  9. Idlewild - To Be Forgotten
  10. The Gaslight Anthem - The '59 Sound
  11. Bleu - Boy Meets Girl
  12. The Temper Trap - Sweet Disposition
  13. Wintersleep - Oblivion
  14. Charlotte Hatherley - White
  15. The Tragically Hip - Queen Of The Furrows
  16. Cruiser - A Gentle Press
  17. The Decemberists - The Hazards Of Love 4 (The Drowned)

As usual, message me for a download. You can't get all of these tracks on Spotify :-)

Barenaked Ladies at the Mountain Winery (Saratoga), 19 July 2010

Sat 07.Aug.2010 15:10

Comments: 0

I'm a big fan of the Barenaked Ladies. I love their music, the time I saw them live in 2001 was once of the best gigs I've been to. They brought heaps of energy and enthusiasm to the stage, and it looked like they were really having fun.

I was disappointed when Steven Page left the band at the sart of 2009 -- his voice defined many of their songs, and I was sad that I wouldn't hear him if and when I next saw the BNL live. (Martin's rule of live performances is: always take the opportunity to see your favourite bands and artists live, because you never know when they'll break up, or die.) This disappointment was reinforced when the band released a truly dreadful live recording of their first gig without Page in July of last year. Uh-oh, I thought. Guess that's the end, then.

But no; their new album "All In Good Time" is pretty good. Not a BNL classic, but pretty good nevertheless. Ed Robertson sings most of the songs, but Jim Creeggan and Kevin Hearn both get more time on vocals (2 and 3 tracks respectively). And although I don't particularly like Kevin Hearn's voice in the abstract, somehow I do end up very fond of the tracks on which he takes the lead. (Watching The Northern Lights is sweet and delightful.) Go figure.

But still... a live performance? With the crowd clamouring for favourites like The Old Apartment and One Week that Steven Page used to properly belt out? My brother-in-law Mick mentioned to me a few months ago that the BNL happened to be playing a few gigs in California while we were going to be there. Despite my worries, it was too good an opportunity to pass by, especially because of the really cool-looking venues like the Mountain Winery. So tickets were bought.

Whoa, what a great evening.

First of all, the Mountain Winery is a lovely venue. You drive a winding road through the Saratoga hills to get there, and once you hit the car park you have a fabulous view out over Silicon Valley below. If you are willing to splash out the dough, you can have a gourmet dinner before the concert on one of the winery decks. And the stage itself is placed nestled in an intimate open-air amphitheatre at the heart of the estate, with vine-speckled slopes in the background. The seats have cup holders so you can enjoy a glass of the local wine with your music. It is very much a premium concert experience rather than a mere gig.

Another thing that made the evening great was that we took Fiona with us -- this was her first concert! Fiona loves If I Had $1,000,000, and the BNL struck me as a good band to see as her introduction to live music. ("Daddy, will they be playing real instruments?") She had a fantastic time, spending a good portion of the time dancing on her seat. Every few minutes she would tug on my arm and shine a massive grin at me. I love to see her so happy.

And the music itself? Wonderful. The band looked happy and relaxed on stage, and just as when I saw them before, they looked like they were genuinely having fun, doing something they love. Sure, the songs sound different without Steven Page's vocals, but they have clearly adapted, and found new treatments for the old songs in his absence. But the band was in the groove, and the audience was thrilled. The atmosphere was fantastic. If, like me, you had any doubts about going to see them in the post-Page era, put them to rest. They've still got it.

Set list:

  1. Who Needs Sleep?
  2. The Old Apartment
  3. Falling For The First Time
  4. Every Subway Car
  5. Easy
  6. Maybe Katie
  7. Another Heartbreak
  8. Tonight Is The Night I Fell Asleep At The Wheel
  9. Sound Of Your Voice
  10. It's All Been Done
  11. Pollywog In A Bog
  12. You Run Away
  13. Blame It On Me
  14. Four Seconds
  15. Big Bang Theory Theme
  16. One Week
  17. To Little Too Late
  18. Pinch Me
  19. If I Had $1000000

Encore:

  1. Ordinary
  2. Watching The Northern Lights
  3. Light Up My Room

Finally, an amusing note about the set lists that I post to my gig reports. I don't take notes during the show; instead I memorize the set list using scenes and pictures I compose as the songs are played. For example, the first three songs of this concert formed into an image of someone asleep in a bed (Who needs sleep?) in an apartment (The Old Apartment), with a burglar falling down as he climbs through an open window (Falling For The First Time). It's a simple trick, but it only really works for bands whose songs and lyrics I know well.

Normally I hold the pictures in my head for a day or two, but unless I revisit them, they fade away quickly. The curious thing about this concert was that I found myself remembering the images I had composed for the BNL gig I attended back in 2001. For that one, the first picture was of someone showing up late for an date at a bar (Too Little Too Late), having a big drink (Alcohol), telling his life story to his date (Life, In a Nutshell), then falling off his bar stool (Falling For The First Time).

I hadn't recalled that picture for nine years, and then all of a sudden it's right there again. Funny how the mind works.

The New Pornographers at The Fox (Oakland), 18 July 2010

Wed 21.Jul.2010 17:59

Comments: 2

Disappointed and annoyed.

First of all, I didn't book my ticket early enough, so I was stuck up on the balcony. The Fox theatre has a fabulously sumptuous interior, but the balcony seats are crappy nevertheless: cramped, uncomfortable, cold, and far too far away from the stage.

Secondly, the ticket said 19:30 (7:30PM, actually, because we're in the US), but the New Pornographers weren't on stage until 21:45 because of the two support acts. Imaad Wasif was on first, and produced an amiable blend of stoner prog rock with alt-country elements, but I was feeling impatient by the time the Dodos came on, and just plain bored after two hours of music I didn't come to see. The Dodos' intensely drum and percussion-based music is something I would lap up under other circumstances; but as a second support act I would gladly have paid a higher ticket price to have them removed from the bill.

The worst thing, though, was the sound, which is the worst I have ever experienced at a gig. It was muddy and indistinct, and it sounded like they were playing at the bottom of a well. Which was actually the case up on the balcony, I suppose. The only thing I could hear clearly were Kurt Dahle's drums. I literally could not make out most of the words they were singing. I don't know if this was an artifact of the New Pornographer's sound setup, or because of the acoustics at the Fox, but it was an enormous let-down. I love their crisp melodies and bright voices, but I just couldn't hear them. When they started playing "Sweet Talk" -- one of my favourite songs of theirs, and impossible not to include in the set, given the byzantine décor -- I almost wanted to cry at not being able to hear the layered vocals.

Finally, I'm annoyed at myself for not doing anything about this. Throughout the concert, I noticed people getting up from their seats on the balcony, and walking out. I suspect that these folk knew better, and were heading downstairs for the general access floor area, no matter what their tickets said. I'm annoyed that I just sat there and didn't even try to blag my way past the ushers. What's the worst that could have happened? That they said no and sent me back to my seat? What's the best that could have happened? I might actually have enjoyed seeing one of my favourite bands.

Note to self: don't put up with shitty seats. Note to everyone else: avoid the balcony at the Fox.

Set list:

  1. Sing Me Spanish Techno (TC)
  2. Up In The Dark (T)
  3. Myriad Harbour (C)
  4. Crash Years (T)
  5. The Laws Have Changed (EV)
  6. Jackie, Dressed In Cobras (TC)
  7. Adventures In Solitude (C)
  8. Twin Cinemas (TC)
  9. Jackie (MR)
  10. All The Old Showstoppers (C)
  11. Go Places (C)
  12. Moves (T)
  13. Your Hands (Together) (T)
  14. My Shepherd (T)
  15. Use It (TC)
  16. Silver Jenny Dollar (T)
  17. Mass Romantic (MR)
  18. The Bleeding Heart Show (TC)

Encore:

  1. Challengers (C)
  2. The Slow Descent Into Alcoholism (MR)
  3. Testament To Youth In Verse (EV)

MR = Mass Romantic, EV = Electric Version, TC = Twin Cinema, C = Challengers, T = Together

Dan Le Sac vs. Scroobius Pip at Paradiso, Amsterdam, 1 Apr 2010

Sat 03.Apr.2010 21:25

Comments: 0

Sweet little gig. Dan Le Sac's big beats sounded awesome in the small Paradiso venue, and Pip's rhymes carried more weight in person than they do on disc. Watching him perform Angles live, putting on different hats and glasses as he switches points of view in the song, added even more emotional weight to the song, and left the audience subdued... but not for long. The second part of the set built up to a huge finale that had the whole room jumping and getting "nice and sweaty." The recorded version of Letter From God To Man has an enormous, spiky and angular outro, and Dan kept it spinning for a long time — just what the crowd wanted.

Set list:

  1. The Beat That My Heart Skipped (Angles)
  2. Sick Tonight (The Logic Of Chance)
  3. Magician's Assistant (Angles)
  4. Look For The Woman (Angles)
  5. Stake A Claim (The Logic Of Chance)
  6. Angles (Angles)
  7. Last Train Home (The Logic Of Chance)
  8. Snob (The Logic Of Chance)
  9. Get Better (The Logic Of Chance)
  10. Thou Shalt Always Kill (Angles)
  11. Great Britain (The Logic Of Chance)
  12. Letter From God To Man (Angles)

Encore:

  1. Back From Hell (Angles)

Play, work, communicate

Wed 31.Mar.2010 17:40

Comments: 0

Play, work, communicate

My brain reads it as "Plorky."

Dutch politics is awesome

Sun 07.Mar.2010 10:54

Comments: 0

To people in the UK and US, Dutch politics can look like a confusing mess, but fortunately we have Peter-Paul Koch to explain it all.

In the web development world, ppk is well-known for his web browser compatibility tables, founding Fronteers (the Dutch professional organisation for front-end developers), and more recently his work on mobile browsers. But he is also a historian, which shows in articles like his amazing dissection of the new <time> element in HTML5, and the introductions to Dutch politics he has written over the last couple of years.

Since the fall of the Dutch government two weeks ago, ppk has created a separate blog in which he is writing lots of great stuff about Dutch political history, the political parties in play for the upcoming general election (there are many), and the ups and downs of the race itself, such as last week's local elections.

If your Dutch isn't good enough to read the native news sources, ppk is definitely the best source of background on this highly entertaining political contest:

About

Legends of the Sun Pig is Martin Sutherland's little corner of the web. I'm a web developer operating out of an abandoned underground nuclear bunker somewhere in Northern Europe.

Me, elsewhere

Something nice for you

Hot Chip - I Feel Better

Hot Chip - I Feel Better. Weird and awesome. Video by Peter Serafinowicz. Yes, him.

Archives

Blog

Quick reviews

Something nice