10/30/2007

XAML readability

I've recently started learning Windows Presentation Foundation development. WPF presents an entirely new way of defining the UI and its behavior, eXtensible Application Markup Language or XAML (pronounced 'zammel'). While I can see the benefits of using a markup language for defining the UI, my first thought after having written a few test programs was how horrible XAML was to read and write. When writing procedural code I've always been very particular about writing code that is extremely readable. Well, not always. Like most developers, I've learned this the hard way. Once you've spent hours trying to figure out what some piece of code is doing, you start to appreciate well-formed code. Also, I haven't really worked with HTML or XML or any other markup language.

So the obvious answer was to use a tool like Microsoft Expression Blend. After having tried it I remembered a web developer who got angry with me when I asked why he chose to write HTML by hand instead of using a tool. I became a target of a 5-minute rant about the terrible HTML code various tools produced. Now I found myself disagreeing with Expression Blend on how to best format the XAML code. Since then I've adopted a middle ground approach, I use Blend to design the UI, then go through the code and fix what I think is not particularly well coded. I wouldn't dream of coding things like animations by hand. Still, coming from procedural code background, I feel slightly out of place when coding a UI partly in XAML and partly in C#. Yet all the magical things I can do with WPF mean I can't stay away from it. I'm curious to see if the process starts to feel more natural in the future. One thing I can promise, though. I will never, ever like the way XAML looks.

No comments: