[osflash] Architecture of reusable modules with different view per project

João Saleiro joao.saleiro at webfuel.pt
Wed May 7 09:52:29 PDT 2008


Hello,

I am starting now with PureMVC. I was a Cairngorm adept (and before 
that, ARP), but Cairngorm failed me when I started working more and more 
with Modules.

I studied PureMVC with the multicore examples, and both the architecture 
and workflow convinced me.  I am not 100% comfortable with PureMVC yet, 
but I'm already testing it on a real project.

I am trying to improve code reusability, and I need some advices to 
achieve a best-practices solution to the problem I'll describe below. 
This might be a common problem when someone starts building larger 
projects, while reusing code, and maintaining the smallest dependencies 
possible between modules. I'll try to explain with an example.

We have organized our workflow for reusing code between projects the 
following way:

- we have a folder where we put everything that's needed among several 
projects (our library);
- in each project we add the library to the classpath of the project.

For example, about 90% of our projects need a custom "LocaleManager " 
module. A LocaleManager is something composed with a view, a model and a 
controller, that allows users to add new languages to our RIAs. The 
functionality is 100% equal in every application. So we decided to 
create a Module that resides on our library path, and the Module has 
it's own MVC architecture based on PureMVC multicore.

The thing is that while the functionality is 100% the same in every 
application, the view might change. Not only in terms of (css) style, 
but also in terms of what and how things are shown to the user.

So I thought in removing the View from the MVC of the Module, putting it 
on the Main application, and when I load the Module I would inject the 
view.  I created an IViewReceiver that my Module implements, with a 
function inject(mediator:IMediator, addView:Boolean):void .
The implementation of this function would consist on registering the 
mediator on the facade of the Module, and making and addChild of the 
mediator.getViewComponent() if the addView flag equals true. If my 
module has more than one component, I have to call the inject method for 
each component I want to register with the Module' Facade.

I am implementing this right now, but I'm not sure if it's the best 
option, and even if it works. I wonder if there is a established 
best-practice out there for this case. Do you think that my solution 
will work? Is there a better one?

Summarizing, what I need is to have modules in a library shared between 
projects; Each module is almost a full application, without the view (it 
can have the view coded on the same packaged, but it's not included by 
default) so it's a MVC without the V; The guy who creates the 
Application that uses the module must have the possibility to create 
it's own view for that module; The modules must be independent of the 
applications where they are used, but the applications can be dependent 
on the modules.

Thank you,

João Saleiro

-- 
	João Saleiro

Email/MSN: joao.saleiro at webfuel.pt <mailto:joao.saleiro at webfuel.pt>
Skype: joao.saleiro
Tel: +351 916 077 097 / +351 968 203 370
WWW: http://www.webfuel.pt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/osflash_osflash.org/attachments/20080507/20c4b60b/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo.gif
Type: image/gif
Size: 4901 bytes
Desc: not available
Url : http://osflash.org/pipermail/osflash_osflash.org/attachments/20080507/20c4b60b/attachment-0001.gif 


More information about the osflash mailing list