Archive

Archive for the ‘Flex’ Category

Mate vs Cairngorm

February 13th, 2009 Aparna Chaudhary 1 comment

I’ve recently been comparing frameworks for Flex event handling. We are already using Mate in one of our projects. I encountered couple of problems in the usage and thought of exploring other frameworks available on the shelf.

Here are some Pros and Cons of both the frameworks:

Mate:

Pros:

  • Tag based event driven Flex framework
  • Declarative way of Event management
  • Custom Events are inherited from default Flash event; no framework code in the application
  • Uses the event-bubbling to catch the events with the EventMap without defining a bunch of wiring code

Cons:

  • State changes are to be notified explicitly to all the associated views by making use of property injection
  • Application can fail silently when you inadvertently misspell the name of the event parameter; compiler checking on tags in EventMap is missing
  • Chances of bloated MXML file since the Event dispatch logic is composed into the MXML

Cairngorm:

Pros:

  • Singleton Model – Uses Observer pattern to refresh all associated views on state change
  • Command Pattern – Clearly defines the Unit of Work. Reduces chances of bloated MXML files
  • Introduction of Business Delegate can expedite development process in projects with different teams for Client and Server implementation. Delegate can be mocked by the client development team to return dummy data.

Cons:

  • Makes codebase bit verbose
  • Custom events are inherited from CairngormEvent which introduces tight coupling between the application and the framework code

As per me, Cairngorm is more suitable for enterprise application development with huge development teams. Use of command pattern can really expedite the development process. Mate on the other hand is more suitable for small applications. However, I would expect one improvement in Mate to add compiler checking on tags in EventMap. Sometimes it really sucks when you realise there are some typos only at the runtime when you application breaks.

References:

http://www.adobe.com/devnet/flex/articles/cairngorm_pt1.html

http://mate.asfusion.com/

Categories: Flex, RIA Technology Tags: , ,

Getting Started with FlexUnit and Maven

December 18th, 2008 Aparna Chaudhary No comments

flex1Today I created my first unit tests for Flex code using FlexUnit. Later I integrated the tests with the maven build using Flex Mojos. Flex-Mojos is a collection of maven-plugins created to work with Flex.

We have to use the Flex Compiler Plugin. This plugin is basically used to compile the source files and run tests. This plugin has 5 goals which are bound to different maven lifecycles. I chose to explicitly specify goals that I want maven to run. Maven has a default value for testSourceDirectory as src/test/java. For using Flex mojos, we have to specify testSourceDirectory as src/test/flex. Make sure all your tests are created under this directory.

	<build>
		<sourceDirectory>src/main/flex</sourceDirectory>
		<testSourceDirectory>src/test/flex</testSourceDirectory>
	        <plugins>
		    <plugin>
			<groupId>info.flex-mojos</groupId>
			<artifactId>flex-compiler-mojo</artifactId>
			<version>${flex-mojos.version}</version>
			<extensions>true</extensions>
			<executions>
			    <execution>
				<goals>
				    <goal>compile-swf</goal>
				    <goal>test-compile</goal>
				    <goal>test-run</goal>
				</goals>
			    </execution>
			</executions>
			<configuration>
			    <locales>
				<param>en_US</param>
			    </locales>
			    <contextRoot>/</contextRoot>
			</configuration>
		    </plugin>
  		</plugins>
	</build>

Next thing is to add Flex Unit dependency in the dependency section.

	<dependencies>
		<dependency>
			<groupId>flexunit</groupId>
			<artifactId>flexunit</artifactId>
			<version>0.85</version>
			<type>swc</type>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>flexunit.junit</groupId>
			<artifactId>flexunit-optional</artifactId>
			<version>0.85</version>
			<type>swc</type>
			<scope>test</scope>
		</dependency>
	</dependencies>

You would also need flash player installed on the build server. In case if you end up with OutOfMemory error, increase the heap size using MAVEN_OPTS in mvn.bat file.

SET MAVEN_OPTS=-Xmx128m

If you need more help, you can always refer the FlexUnit Example.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes