Pipe Architecture

Here’s a working architecture for modular applications utilizing PureMVC pipes.

Pipe Architecture

This allows you to have modules that load modules that load modules, etc. The modules communicate to each other via Pipes.

The sample diagram illustrates a parent, child, grandchild relationship (An app that loads a module that loads module). You can of course, have multiple siblings.

AS3 PureMVC Dynamic Modules

Okay, I’ve had some questions on refactoring my PureMVC dynamic modules classes to support AS3 projects (i.e. no flex).

I’ve posted a sample app that does just that.

I threw this together off the cuff, so don’t expect too much 🙂

The app (10K) simply loads 6 modules dynamically, 3 “RedTint” modules and 3 “GreenTint” modules (4k each). The app sends a notification every second containing a random color. The loaded modules pick up on this notification and display the color – each with their corresponding tint.

Keep a close eye on Cliff’s Pipe utility as these classes may soon be obsolete 🙂 Until that time, I hope you might find this useful – if you do, drop me a line and let me know.

I’ve got some time between projects if anyone is looking for some RIA development…

Dynamic Flex Modules with PureMVC

I’m rolling out a large project, and I wanted to utilize dynamic modules for scalability.

For those who aren’t familiar will modules, basically, there a great way to encapsulate “pieces” of your application. A trivial example would be a small ‘shell application’ that once the user logs in, loaded the appropriate use-case module. If your working in a team environment modules make for an easy project divide-and-conquer approach.

I’ve been using the PureMVC framework lately and figured adding support for dynamic modules wouldn’t be too difficult as Cliff and the gang have already been hard at working getting the framework changes in place to make this possible (replacing singletons with multitons etc).

Well after some working laying this out, I’m glad to say I’ve got it working. Check out this sample app Dynamic Mortgage Demo.

The demo allows the user to get loan quotes from [fictional] banks. The demo allows the user to dynamically load / unload bank “modules.”

The application and modules are very well encapsulated. Here’s whats required from each party…


Must compile with…

A reference to any interfaces the modules loaded at runtime implement (ILoadableModule in our case).

A reference to any subclasses of mx:Module the modules are using (PureMVCLoadableModule in our case). This is only necessary if your subclassing mx:Module.

That’s it.

Here’s the integration point on the modules end…

The modules facade implements an “InitializeMapping” function which maps application notification names to local (module) notification names [inbound mapping]. The function also defines module notification name to application notification name [outbound] mappings.

Here’s an example

override public function initializeMappings():void
outboundMappings:Array = new Array();
outboundMappings[QUOTE_GENERATED] = EventNames.LOAN_QUOTE_READY;

inboundMappings = new Array();
inboundMappings[EventNames.REQUEST_FOR_LOAN] = QUOTE_REQUESTED;

And thats the extent of what our application and modules know of each other. The rest of the ‘work’ is done automatically by a few interfaces / subclasses I wrote on top of PureMVC to make this possible. (i.e. your modules facade subclasses ModuleFacadeBase etc). No framework changes we’re required just some subclassing here and there.

And the framework is …

We’ll after studying Cairngorm and PureMVC for the past day or so I’ve decided to adopt PureMVC for my next Flex project.

Cairngorm had the scalability and robustness I was after but end the I went with the underdog. The best thing Cairngorm has going for it is the Adobe Machine and thus a large adoption pool. Kudos to Steve Webster and the rest of the Cairngorm authors, it is a well thought out and obviously scalable framework.

PureMVC seems cleaner to implement and addresses most of the issues you’ll find people gripping about with Cairngorm.

Anyways, time will tell, for now I’m jumping on the PureMVC bandwagon – thanks Cliff!!

Flex Architecture Frameworks

I’m gearing up to start some medium scale enterprise projects and thought I’d look up this “Cairngorm” thing I heard talked about at the MAX conference in Chicago. The developers either loved or hated it, so I figured I should check it out. Basically Cairngorm is a design pattern framework for flex, an architect’s tool chest if you will. We’ll it appears that Cairngorm isn’t alone, here’s the lineup I ran across today…




Tom Bray’s EasyMVC

Simeon Bateman’s EasyMVC

(EasyMVC’s share the same name but are, in fact, different frameworks)

The latter two (EasyMVC’s) appear to be lighter weight frameworks, while Cairngorm and PureMVC both seem to be a bit more robust. PureMVC isn’t just for flex it currently supports or is in the process of been implemented in … Flex, Flash, AIR, FlashLite, .NET, Windows Mobile, Silverlight, J2ME, SE, EE, JavaFX, and well… PHP and ColdFusion.

I’m reading into all four frameworks to decide which, if any to further evaluate. I may adopt one for my upcoming projects or use them as spring boards to writing my own framework to help enforce the DP’s I’ve been studying as of late.