26 May 2009 ~ 5 Comments

Namespaces in Flex 4 are the correct choice

I got pinged several times this morning in response to Aral Balkin’s post on the use of namespaces in Flex 4. I can’t get his site to load so I can not comment on his post there. But I feel strongly enough about this matter that I wanted to get something out in response right away.

Namespaces in Flex are the RIGHT decision. No matter how you look at it using namespaces to reference component libraries is how it is done, and how it has always been done. The difference is in Flex 4 you have options about what libraries you get to use. And the thing that you have to actually take into mind is that because of this option you may need to change the way you look at the code in the Flex SDK. Flex is not a language. The SDK has 2 languages that are used to compile content to SWF, those are ActionScript 3 and MXML. Building applications for Flex 4 means choosing which version of the compiler and the mxml language you wish to use, and then picking and choosing components from whatever UI library you wish (Halo or Spark).

Regardless of what the classes in Spark are named this would have been the workflow. To migrate an application from Flex 3 to Flex 4 you would have had to change all the namespaces in your application to the MXML 2009 namespace, and then added in the the new components you wished to make use of. The fact that the components in Spark don’t have names with superfluous extra characters would not have changed the workflow in the least. I have migrated apps to Flex 4, before the name change, during the time the classes were named poorly, and after. Because of the advances in the language, Flex 4 requires a new language namespace and allowing users to pick components from their choice of UI frameworks by using namespaces is invaluable.

So I am sorry Aral, on this topic I feel you are dead wrong. Namespaces are part of XML (and therefore MXML) and they are the correct way to make ambiguous nodes unique. A Panel is still a Panel regardless of how it gets skinned and giving it another name when there is already infrastructure for allowing the two to coexists would be an epic FAIL.

So again I want to say thanks to the Flex SDK team for not screwing up the language just for backwards compatibility sake. Once Flex 4 has been released and the upgrade path begins, people will be very happy that the classes they use are not misnamed. And new people coming to the language will not have to be explained to why the Flex 4 components couldn’t just be named what they are.

5 Responses to “Namespaces in Flex 4 are the correct choice”

  1. Greg J 26 May 2009 at 1:37 pm Permalink

    Excellently phrased Simeon and I agree completely.

    I also find it odd that Aral is complaining about the workflow and headache of migrating an existing Flex 3 app that works now to an alpha version of Flex 4, and having to make additional changes as development on the SDK progresses to make his alpha version in Flex 4 continue to function.

  2. Aral Balkan 26 May 2009 at 2:48 pm Permalink

    Simeon,

    I’m basically stating that it was dead simple to port a Flex 3 app earlier in the year to the Fx-prefixed version of Flex 4 and that it was not so porting a different (much smaller) app to the latest Flex 4. That’s been my experience.

    I can’t see, for example, how having CSS with namespaces is the same level of complexity as CSS without.

  3. Simeon 26 May 2009 at 3:36 pm Permalink

    Hey Aral,

    So your issue really is specifically with CSS namespaces. I will concede that I actually didn’t think that was a feature that needed implementing at all. With type and class selectors as well as the new decedent selectors that are already available in Flex 4 the CSS Namespaces seem unnecessary.

    That being said, we are talking about porting a Flex 3 app to Flex 4 so adding

    @namespace “library://ns.adobe.com/flex/halo”;

    to your css file should give you backwards compatibility for your applications. Then you only need a CSS namespace for the new components you use from the Spark library. So it doesn’t appear as though it is such an enormous undertaking to migrate.

    That assumes you already changed the language namespace and added the mx prefix to load the halo library. But those thing would have been needed regardless of the CSS namespaces.

  4. Jason The Saj 28 May 2009 at 12:29 pm Permalink

    Can we get an updated example…

    I’ve downloaded both 4.0.0.4904 & 4.0.0.7282 and I am having difficulty getting a simple basic application working.

    I am not trying to port a Flex 3 app. I just want to start experimenting with “Gumbo” and I can’t seem to get an application with the proper namespace working.

    Every example I’ve seen online seems to break (either they’re old Fx prefix, or mx: prefix).

    It’d be nice to just have an updated example that’s not from 2008 or February 2009.

  5. Simeon 31 May 2009 at 9:50 pm Permalink

    Hey Jason,

    I was gonna make an updated example for you, but the new Flash Builder Beta was just released on http://labs.adobe.com and when you create a new application it has all the right stuff set up.

    So its very easy to build an example with this new build.

    HTH,
    sim


Leave a Reply

PHVsPjxsaT48c3Ryb25nPndvb19hYm91dDwvc3Ryb25nPiAtIEhpISBNeSBuYW1lIGlzIFNpbWVvbiBCYXRlbWFuIGFuZCBJIGFtIGEgd2ViIGFwcGxpY2F0aW9uIGRldmVsb3BlciBzcGVjaWFsaXppbmcgaW4gdGhlIEFkb2JlIEZsYXNoIFBsYXRmb3JtLiAgSSBhbSBhbiBBZG9iZSBDb21tdW5pdHkgRXhwZXJ0IGFuZCBhbiBBZG9iZSBDZXJ0aWZpZWQgVHJhaW5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