Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / weblog

Dominic Cronin's weblog

CSS3 doesn't look so bad to me (so far)

Posted by Dominic Cronin at Sep 23, 2007 12:55 PM |

By way of my regular dose of Ajaxian, I came across an article by Alex Russel, describing CSS3 as a "giant serving of FAIL". Alex, I'm afraid I'll have to disagree with you.

Firstly though, thanks Alex, for presenting your views in a sufficiently provocative way to get me to go and look at the current standards work. For CSS (or anything that will have to wait for browser support to become useful) I wouldn't usually bother until after a recommendation is out, and it's interesting to see what's coming.

Alex is unhappy that the proposals' focus on CSS namespacesCSS Print Profile and CSS Advanced Layout seems to have taken priority over some things that he would like to see. He's keen on being able to have "mix-in" styles so that you could import the style from another existing style into your rule. He'd also like to see the ability to define and use variables in a stylesheet, for example for defining named colours.

On the face of it, there's nothing wrong with these suggestions, but to me they are frills, and worse yet - any such frills will reduce the likelihood of coherent and reliable implementations by the various browser vendors. Making sure that all the browsers work properly when multiple classes are applied to an element would solve most of the pain addressed by mix-in styles, and variables are probably more suitable for server work, ideally in a CMS.

Now on to the things he doesn't like in the proposal. He describes CSS Print Profile and CSS namespaces as "turds". Well personally I don't have much of a use-case for Print Profile yet, so I'll sit on the fence and say it's probably good for the people that need it. CSS namespaces turns out not to be a turd at all, but a minor enhancement that will remove various headaches from people who are trying to style non-trivial XML documents.

I've saved the best till last though: Alex describes the CSS Advanced Layout module as a "cluster-fsck". I don't know what one of those is, but if it's anything like a cluster-fuck, I don't get his point. One of the areas of CSS most needing attention is how we do page layouts. The normal Internet web site visitor these days expects to see a couple of navigation areas, along with sidebars, footers etc., etc. Now I'm pretty much a middle-hitter in the world of CSS. I know way more than your typical Frontpage man-on-the-Clapham-omnibus kind of guy, but I'm nobody's guru either. I'll be straight: right now, speaking as a middle-hitter, getting a standard three-column layout is hard. Too hard. The solution as proposed for CSS3 looks like it will make sense to ordinary folks and middle-hitters. I wish Alex hadn't attempted to ridicule this as Ascii-art, because it's worth more serious attention than that. In addition to solving the three-column layout problem, there's all sorts of other goodness, like tabbed layouts, and the potential for things like newspaper layouts that you probably wouldn't have attempted without tables.

I have no friends

Posted by Dominic Cronin at Sep 15, 2007 11:05 AM |

So flushed with my success on LinkedIn I joined Facebook.

er.. yeah ... my success on LinkedIn huh? Right - well I've got 136 connections - cool eh? Full of life-changing goodness! Give me a break!

And then on Facebook, they aren't called connections, they're called friends - so I joined, and the first thing it told me was "You have no friends".

What do we do this for? LinkedIn has been completely bloody useless to me, other than giving me another compulsion to feed. To be honest, all it's good for is finding out when former colleagues change jobs. Hey - even if you get escorted off the premises by a security guard, at least you can still spam your contacts eh?

But perhaps enough youthful trendliness will rub off from Facebook on to me to stave off the inevitable mid-life crisis for another year or two. Ain't holding my breath though.

The price of freedom

Posted by Dominic Cronin at Sep 05, 2007 08:55 PM |

via Ned Batchelder, I came across the story of an American student, Star Simpson, being arrested for wearing an electronic circuit board as a fashion accessory while visiting an airport. She hadn't threatened anyone, but the police afterwards seemed to be giving the impression that they had seriously considered shooting her. Where does this craziness come from? When I visit my home town this coming weekend, it's quite likely that I'll be greeted at the airport by a couple of policemen toting machine carbines. This didn't use to be normal.

Let's get this straight. I was born and grew up in a free country. These days I live in a different country; also free. The police here carry guns, which I dislike, but so far I haven't seen them swaggering around with machine carbines. As a kid growing up in the UK, the prospect of seeing the police kitted up like that was unthinkable.  Any applicant to the police force would have been weeded out damn smart if he'd shown the inclination to engage in such machismo.  These days, it's just normal.

Many years ago, I visited Canada, (another free country). The local news on the day I arrived was of a local youth who had gone crazy and charged at half a dozen police officers with a knife. The officers in question were armed with side-arm batons, but they just shot him. I thought: cowards. The locals just shrugged as though it was normal, and it was. A good shoot, eh?

In the UK, we got through most of the IRA years without getting too crazy. If, on a tube train, someone inadvertently failed to make their ownership of a bag obvious to their fellow passengers, you might feel the occasional flush of fear, but there was no danger of them being shot for it.

That's my point. The price of freedom is that we all accept a little fear in our lives. Life isn't safe. Living is fatal. If the sight of public servants in kevlar and gunmetal makes you feel safer, then we should feel sorry for you. You aren't safer - and you just gave game, set and match to the people who would disrupt our "free" existence. Arresting a student for having a techno-chic fashion sense is the same thing. It's meant to make people feel safer. It's meant to justify the existence of the airport swat teams and all the bravado. It doesn't make anyone safer or justify anything. If anything, the more a society relies on gun law, the more likely it is that such injustices happen, and the further from freedom we all are.

If she'd been getting on a plane, her clothing would have been scanned along with her other belongings. If it had been a bomb, she wouldn't have been allowed on the plane, and she would have been arrested. What actually happened was that she was meeting someone. She wasn't even going to fly. So then where's the difference between an airport and any other public place?

Terrorist threats are most effectively countered by quiet unassuming intelligence work. The people who do such work presumably are brave and rarely swagger.

I really hope Star Simpson is exonerated of the phony charges of disorderly conduct and "possession of a hoax device". It strikes me that the ones guilty of disorder were the officers who drew their guns in a public place and threatened her life. The second charge sounds easier. She can easily show that her device was genuine. Not a bomb, but definitely a device.

O say, does that star spangled banner yet wave
O’er the land of the free, and the home of the brave?

Now you have two problems

Posted by Dominic Cronin at Aug 22, 2007 07:55 PM |

There I was innocently browsing through a post by phil Haaak, when I accidentally clicked through an off-the-cuff incidental link he'd included along the way.  Lo and behold I found myself at the blog of the esteemed Jeffrey Friedl (the guy who wrote the book on regexes) reading a post on the origins of the gag about "now, you have two problems".

 

Geekish humour, I suppose, but very entertaining.

 

BTW - subscribed, even though there's barely a regex in sight.

Vechtloop

Posted by Dominic Cronin at Jun 18, 2007 05:05 PM |

Yesterday, I took part in the Vechtloop, a running event held in Weesp, which is near Amsterdam.  I ran in the 15km event, and came in with a (for me) respectable time of 1:18:44.


Although the start involved a bit too much hanging around in the rain, once we got going, the weather improved.

You can see the route here:

http://www.sanoodi.com/route/dominic-cronin/46589/vechtloop-15km/

OK - so now I'm sick of that chinese-ish guy staring at me

Posted by Dominic Cronin at Jun 15, 2007 09:55 PM |

I'm re-installing the Orcas beta again. That's OK - it's a Beta - you expect that kind of thing. But hang on a second.... isn't that the same sort-of-chinese-guy-but-with-arnold-schwarzenegger's-chin that was staring at me when I installed VS2005? And the vaguely-chinese-ish girl in the lab-coat? And what about the guy with all the teeth that might be sort-of-indianish-but-maybe-southern-european-with-a-deep-tan?


Oh heck - I don't blame Microsoft per se. My own company's stock-marketing-photos are the subject of a previous rant, but honestly - I keep wondering if any of those people have ever written a line of code, and if not, why TF are they staring out at me as I install my tools?

It just strikes me that Microsoft's marketing department has carefully chosen these images to avoid offending anyone, like say with the notion that a programmer might be a white bloke with a bit of a beer belly - in the second half of his forties. Don't want to do any stereotyping there eh? On the other hand - at DevDays this week, the only good-looking people there were myself and ScottGu. I don't suppose he writes any more code than I do, what with his speaking programme and all.

Anyway - enough! I thoroughly enjoyed Scott's talks - in addition to being  a powerful advocate for his products, he manages to pitch it directly at the well-informed-but-caffiene-starved programmer. Nice one Scott.

Muenchian groupings in XSLT

Posted by Dominic Cronin at May 13, 2007 08:35 PM |
Filed under:

On Friday, a colleage at work asked me how to do something in XSLT. After a minute or so humming and hah'ing I said I'd have to think about it for a while. As it turned out, it took most of the weekend. (OK - as a parent of 2 under-3s, the amount of free time in a weekend is limited, but still, this was a tricky problem.)


The source XML document was something like this:

<list>
    <item>
        <Message ID="first" ">
            <Title>Foo</Title>
            <Body>You can now find details of the blah blah blah</Body>
            <Date>20050612</Date>
        </Message>
    </item>
    <item>
        <Message ID="second" >
            <Title>Bar</Title>
            <Body>Flibble de dee</Body>
            <Date>20050805</Date>
        </Message>
    </item>
</list>

 

Of course, there were lot more messages, but the important point was that my colleague wanted to group the messages by month. That meant that any Message whose Date element's first six characters were the same should be displayed together, no matter where they came in the source document.

 

This turns out to be a non-trivial problem in XSLT, and has been explicitly addressed as a weakness by the people responsible for XSLT 2.0. Anyway - the following works in XSLT 1.1; it's based on the Meunchian grouping technique (aka Fu-Muench-u).

 

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:key name="messages" match="/list/item/Message" use="substring(Date, 1,6)"/>
    <xsl:template match="/">
        <xsl:variable name="messagesWithUniqueMonth" 
	select="/list/item/Message[generate-id()=generate-id(key('messages', substring(Date,1,6)))]"/>
        <xsl:for-each select="$messagesWithUniqueMonth">
            <xsl:sort select="substring(Date,1,6)"/>
            <xsl:call-template name="doMonth">
                <xsl:with-param name="month">
                    <xsl:value-of select="substring(Date,1,6)"/>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="doMonth">
        <xsl:param name="month"/>
        <div month='{$month}'>
            <xsl:for-each select="key('messages', $month)">
               <xsl:sort select="Date"/>
                <p>
                    <xsl:value-of select="Title"/><xsl:value-of select="Date"/>
                </p>
            </xsl:for-each>
        </div>
    </xsl:template>
</xsl:stylesheet>

I had wanted to do something less arcane. I tried various approaches beginning with a variable containing all the dates, and then refining it, but most of the time I ended up with a <xsl:for-each/> unable to consume a result fragment or some such. The Muenchian technique works, even if it is opaque, and nothing else I tried did. I think it's probably possible using a recursive template to create a delimited string of months, but this way is definitely getting added to my toolbox.

 

For what it's worth, I'll recommend that we don't do this at all. The XML being transformed is already generated programatically, and it should be simple enough to add a month field that will make life a lot simpler.

Agile Correctness

Posted by Dominic Cronin at May 02, 2007 07:35 PM |

In his post Getting annoyed at Agile Correctness, Sam Gentile blows off a little steam at the people who engage in religious zealotry regarding agile practices. This amused me rather, as I recently had an encounter in which it seemed I was being accused of not being "agile enough".

 

Me: There are some of these tasks that we definitely need to do first. They are pre-requisites for tasks that need to come later.

Person who shall remain nameless: So you need to know everything before we start? We're in a conception phase!

Me: No - I just said we'll need to do some things first, and then the things that depend on them.

PWSRN: So you need to know everything before we start?

Me: I don't recall any such words leaving my mouth. (While thinking: What part of "we'll need to do some things first" did you manage to mis-translate?)

Whatever! It took a little longer to get there... I guess some people just can't metabolise clue.

 

A few days later, I got back from a short break to find that they'd arbitrarily switched the first and second elbonation phases, failing to note that this broke at least one dependency. Ho hum.

Separated at Birth?

Posted by Dominic Cronin at Apr 25, 2007 01:00 PM |

I know it must be hard to make a favicon (the icon that most browsers will display just to the left of the URL in the address bar), but simply picking a letter and adding bad typography might not be enough. What about these two?

http://www.blogspot.com/favicon.ico

https://partner.microsoft.com/favicon.ico

 

I think we should be told.

 

BTW - If you get bothered by questions from your browser at this point, it's not my fault. Microsoft can't be bothered to use a certificate that joins up with the certificate authorities that Windows trusts. Doh!

Smashing the distraction stack for fun and profit

Posted by Dominic Cronin at Apr 01, 2007 06:20 PM |

In a recent post, Ned Batchelder, said "I was already three or four levels deep on the distraction stack, so I went and looked." This phrase fascinated me. Those of us who write software, or work with other complex technical tasks, often have to solve problems on several levels simultaneously, and I have long thought of this process as being similar to the way functions are called in software programmes.

Each function in a programme is dedicated to performing some task, but it may well need to call other functions to do this. The computer can only deal with one function at once, so it first needs to save the details of the calling function before beginning to process the function that is being called. The usual way of doing this is in a data structure called a stack. (In other contexts, this kind of structure might be referred to as a last-in-first-out queue, or a LIFO.) If the called function needs to call another function, it too "pushes its state" onto the stack before making the call. As each of the called functions finishes processing and returns, the state of the function that called it can be retreived, and that function can carry on where it left off. When that function in turn completes, its state in turn is sitting on the top of the stack waiting for retreival.

When researching a new technique, or finding the solution to a problem, this is often what you do. You get to a point where you can't carry on your current line of research without first solving some other problem. At this point, you make a mental note of where you are up to, and go off to solve the problem, repeating as necessary, and hoping that you don't have to hold mental state for too many things. As you solve each of the secondary problems, you back up to the point at which you got stuck, and at which you are now presumably not stuck any more.

Of course, it's not just when solving problems (in which case you pretty much have to follow this through to the bitter end). Sometimes, you are studying, and you find something that you should understand before moving on. This can lead to the same process of parking your mental state and taking some detour. There is often a choice as to whether you should do this now (stack-based processing) or queue the problem elsewhere for off-line processing. Whether you do this will generally depend on why you're doing what you're doing at the time. In Ned's case, he decided to indulge himself and go and check up an arcane detail of the HTML specification. Under other circumstances, you might have to carry on in the interests of progress and deny yourself the satisfaction of full knowledge.

From now on, when I'm busy with private-time research projects, and free to enjoy the diversions, I'll revel in the notion that I'm somewhere in the distraction stack.