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

*
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


Related Posts

2 Comments so far
  1. E Brent Nelson  March 10, 2010 4:30 pm

    Do you have an example of this in practice? I’m having a hard time wrapping my head around it. I get the basic idea, but implementation is a bit sketchy for me..

    (I know this post is two years old.. :S)

  2. Santanu Karar  April 2, 2010 11:31 pm

    This concept is no doubt good. But the given snippets is not at all adequate. It only creates a lots of questions and confusions. Maybe Harry has the clear view in his mind.

<

Direct TV Offers - usdirect has the best directtv deals