Swiz vs Mate ViewStack – Replace Dummy Glossary View with Live Version

December 9, 2009

Now that I have a simple UI ViewStack framework configured, it is now time to test the incorporation of actual data into the Glossary view portion of the view stack.

I took a standalone flex based Glossary application which had been implemented outside of any framework(beside the flex framework). It uses an xml loader class which I use when coding in both Flash CS4 and Flex. Flex has a nice builtin HTTPService call with an ASyncToken feature but it is not usable in Flash CS4 so I standardized my xml based file loading requests around my hand rolled xml loader class.

I converted the Glossary application to a Glossary component and incorporated it into the Swiz based application framework first. You can view the swiz based resources player here. The view source is enabled, so just right click on the flex application to check it out.

I then incorporated the same Glossary component into the Mate based application framework. You can view the mate based resources player here. The view source is enabled, so just right click on the flex application to check it out.

Now this conversion was quick and dirty but it was much faster to do in Swiz. I could use more of my original work(code) without much change when I wired it up in Swiz(By throwing in a few autowire and mediate metadata tags). When I did the same conversion in Mate, I had to make more modifications to my views and the EventMap was very verbose. I also had to research which Mate based tags I needed to use in the EventMap and how to use them. Steeper learning curve.

In essence, with Swiz I seem to be coding to solve the problem instead of coding to the framework.

Compare the following files between the two framework versions to illustrate the difference:

  1. ResourcesBeans.mxml(Swiz) vs EventMap.mxml(Mate)
  2. ResourcesAppController – compare the code in both versions
  3. ResourcesModel in Swiz was distributed into two Files in Mate Version – ResourcesView and ResourcesAppController
  4. GlossaryView.mxml

Note: I also added an error view that displays a message if the xml data was not loaded properly.

Advertisements

Swiz vs Mate in a Simple Flex based ViewStack Example

December 8, 2009

In my previous post, I implemented a ViewStack control using Swiz. You can review my first example of using the Swiz framework to toggle between the views in a ViewStack here. The view source is enabled, so just right click on the flex application to check it out.

After completing the Flex ViewStack example in Swiz, I then massaged it to be rendered using Mate. The ViewStack example can be viewed here. The view source is enabled, so just right click on the flex application to check it out.

I guess the benefit of using Mate, is that you can easily move the project code to another framework since the EventMap centralizes the injection and mediation behavior in a single file.

The migration issue aside, when using Mate I felt like I had to write more code to accomplish the same thing I just wrote in Swiz. The EventMap and Mate framework require more verbosity to link up the models and event mediation than the Swiz bean based framework. Compare the code in the following files in the two examples:

  1. MainResourcesView.mxml
  2. ResourcesAppController.as
  3. ResourcesView.as vs ResourcesViewModel.as
  4. EventMap.mxml vs Beans.mxml

I really like the Swiz implementation even though it is not as centralized as Mate(Event Map usage).

Although you embed the [Autowire] and [Mediate] metadata tags in your code to reference the Bean instances(This embedding may impede your ability to easily transfer code to another framework), the use of these tags lets me know, for example, when I am in a file what model is being referenced and what data is injected immediately and what events are being subscribed to by just looking at the code without having to reference/setup this info in an EventMap or writing extra getters and setters in a view.

I also did not have to think as much about how to use the Swiz framework as I did with the Mate based one. For me, the use of Swiz was more intuitive.