|
![]() |
Chronicle of the Xul Revolution |
Paul DiLascia, King William's Court Jester of Windows++ fame, wrote a tiny XUL motor for Windope Forms in C# dubbed Motlib. Motlib (http://motlib.net) shows how a bunch of XML tags break the Visual Studio generated spaghetti code lock-in.
#region Visual Studio generated spaghetti code /// <summary> /// required method for Visual Studio lock-in - do not dare /// to touch this code by hand; always use the latest /// and greatest Micropoly Milk Machine /// </summary> private void InitializeComponent() { this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.menuItem4 = new System.Windows.Forms.MenuItem(); this.menuItem5 = new System.Windows.Forms.MenuItem(); this.menuItem6 = new System.Windows.Forms.MenuItem(); this.menuItem7 = new System.Windows.Forms.MenuItem(); this.menuItem8 = new System.Windows.Forms.MenuItem(); // // mainMenu1 // this.mainMenu1.MenuItems.AddRange( new System.Windows.Forms.MenuItem[] { this.menuItem1, this.menuItem3}); // // menuItem1 // this.menuItem1.Index = 0; this.menuItem1.MenuItems.AddRange( new System.Windows.Forms.MenuItem[] { this.menuItem2}); this.menuItem1.Text = "&File"; ... }
vs.
<!-- feel free to change the XUL markup with whatever text or XML editor you like --> <mainmenu id="MondeMainMenu"> <menuitem text="_File"> <menuitem text="E_xit" /> </menuitem> ... </mainmenu>
Read the full story entitled ".Net GUI Bliss: Streamline Your Code and Simplify Localization Using an XML GUI Language Parser" in the Micropoly Prawda November issue online at http://msdn.microsoft.com/msdnmag/issues/02/11/NETGUIBliss/
Paul DiLascia Quotes:
No human programmer would code this way, so why accept it from a mechanical one? A code generator is fundamentally a workaround for something that's missing. You can call it a wizard, but the wizard has no Brain.
GUI resources like menus and forms belong in files that are easily translated not embedded in procedural code instruction.
It's not hard to write a mini-XUL that supports only the widgets you need. XUL - or something like it - is just the ticket to GUI greatness!
Sorry to burst your balloon, but that Form Designer code is editable by hand, roundtrip, without problems.
Not to mention that the two pieces of text in the example do not even describe the same bit of UI - a bit sloppy, there.
Additionally, generated code is much better than XML config files when you actually have to program against the controls in your UI (which is always). With generated code, you dont have to write screeds of runtime-error prone code to extract your controls from the 'control-DOM', and cast them to their appropriate type, and hook up event handlers.
I'd rather let the IDE do the donkey work.
Yeah,
I really have to agree with IM. That with the visual studio IDE, using XUL to create all screens would be terribly slow and error prone.
However I think an IDE could be created that would easily be able to add error-checking at compile time and even Intellisense-type code completion after reading in the XUL files.
The XUL file would of course have to be compiled into a resource file of some kind, or translated into the equivalent C# code as shown in the example at compile-time. I.e. the XUL file could not be edited after compilation becase then a button might be removed or something that the code calls on to exist.
There may even be solutions to this problem as well.
So although you are right, IM, with the current state of IDEs and compilers, I think that a more open-minded approach can be found.
-Rich
Posted by: Rich at December 4, 2003 06:41 PMYou're right Rich.
It looks like MS have overcome the shortcomings of XUL with XAML - you get to program directly to the objects in your UI 'tree'.
I suppose I was to some extent reacting to the tone of zealotry I detected in the original post.
|
Please send comments on our web pages to our public xul-talk mailinglist or to a member of our web team. | Copyright © 2003, 2004, 2005 Open XUL Alliance |