Sunday, May 25, 2008

Swing Does Components Better Than Component Libraries Do

I'm currently trying to get a handle on Macromedia Adobe Flex using the free, open-source Flex SDK. Flex is a set of tools to create flash-based "applications" using XML UI definition and Actionscript for everything else.

It seems that Adobe has adopted some Microsoft conventions for programmatic UI creation and management. In particular, components in Flex have a long and convoluted lifecycle. In Web Forms, I never understood why I shouldn't create child controls in my Control's constructor; Flex's UIComponent has a createChildren() method. I still don't know why I shouldn't create child controls in the constructor.

In my Swing programming, on the other hand, I don't seem to run across these problems. As far as I know, a Swing component has one and only one step in its initialization process - the constructor. That certainly makes things simpler. I don't have to wonder "What happens if I put this here?" or, more commonly, "Why does this thing not work? Oh, somebody messed up the initialization code."

Actually, most of my frustration here is directed to ASP.NET 1.1. Things may have gotten better in later versions (though I doubt it), and I don't really know how good or bad it is in Flex land. Still, this dredged up bad memories for me. Thick base classes suck!

2 comments:

Marc said...

It is a bit disanalogous to compare GUI frameworks and web frameworks, unfortunately, that is exactly what WebForms tries to do, making things far harder than they need to be. Interestingly, Microsoft has put out the ASP.NET MVC Framework, a Rails/Monorails like framework that may be quite nice (I haven't looked at it).

Normal WinForms programming lets you just construct child controls in the constructor, which is an improvement, though I think Swing has a huge step up in its design.

Is Flex worthwhile? From what little I know about it, it seems like something any major site would wish to avoid as I suspect it ruins SEO and has all the compatibility problems of any flash app. But it seems like a lot of people I know are getting into Flex.

Daniel Yankowsky said...

Flex does support accessibility to an extent, but I don't know if search engines index a swf's metadata. Google's crawler might extract strings from a swf, but I make no promises. To your point, Flex is probably better for things that exist behind an authentication system. In an enterprise web application, you're probably able to provide better search than a web crawler would provide anyway.