Subscribe

  • Subscribe  

A suggested Cairngorm based modular architecture

Posted by Harry Vikatos | July 17, 2008 .

There have been a few discussions around after Flex 2.01 introduced the concept of modules, about issues with using modular architecture along with Cairngorm framework. I will not address here problems arising from using singletons along a shell and loaded modules (as done here), but rather present a way to integrate a Cairngorm based shell app with one or more also Cairngorm based modules.

My starting point was that I didn’t quite wanted modules to be ‘crippled’ apps putting very specific requirements on how the shell is built. So I didn’t want modules to share either the FrontController nor the ModelLocator with the shell. On the other hand I thought treating the shell as a ’service’ to the module, was a neat approach. This way I would centralise all interfaces to external servers into the shell and also use the shell as a possible communication bus between modules.

This approach is depicted below.

cg_modular_architecture A suggested Cairngorm based modular architecture

The module uses a Service Delegate that implements a specific interface. The shell also has a Service Delegate that specifically implements that same interface. When the shell loads an instance of the module, it passes an instance of its own Service Delegate implementation for this module. The module can then use that to service its commands execution. Notice that the module makes minimal assumptions about the shell. Actually the shell may not be a Cairngorm app at all. All it needs is to have an implementation of the module Service Delegate. Furthermore the module should implement a mechanism for gracefully handling the case the shell has not passed in a Service delegate implementation.

Here’s a snippet for a module Service Delegate:

public class ModuleService implements IModuleService
{
public static var shellServiceDelegate:IModuleService;

public static function getService():IModuleService {
if(shellServiceDelegate!=null) {
return shellServiceDelegate;
} else {
Alert.show(”Shell service not found”, “Error”);
return new ModuleService ();
}

}

//put all functions that comprise the interface implementing a default (shell-less) behaviour

}

Leave a Comment

If you would like to make a comment, please fill out the form below.


Name

Email

Website

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Comments


Related Posts


Cox special offers ||| Verizon High Speed Internet ||| Comcast cable tv