Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Retrieving Proxy Between Modules  (Read 12064 times)
chitchu
Newbie
*
Posts: 3


View Profile Email
« on: August 01, 2008, 02:49:01 »

Right now, we are retrieving the proxy by having the facade instance of the other module within the module that requires the proxy.  Let's say for example, module A has a proxy called UserAccountProxy and module B needs to access the UserAccountProxy from module A. 

This is how we are doing it currently within module B:

:
var facadeA:ModuleAFacade = ModuleAFacade.getInstance ( ModuleAFacade.getKey() );
var userAccountProxy:UserAccountProxy = facadeA.retrieveProxy ( UserAccountProxy.NAME ) as UserAccountProxy;

Now my question, is there any other way to loosen the coupling between modules? A way that I don't need to import Module A's facade?

Thanks in advance.
Logged
ramanuja
Jr. Member
**
Posts: 17


View Profile Email
« Reply #1 on: August 01, 2008, 08:26:09 »

chitchu,

Have you considered Pipes? The solution that you are looking for may be Pipes.

Using pipes, ModuleB can send a message though a pipe connected to ModuleA requesting for the data that ModuleB wants. ModuleA can then send the data through another pipe that is connected to ModuleB.

This way, the two modules are decoupled.

Ramanuja.
Logged
ashier
Courseware Beta
Newbie
***
Posts: 1


View Profile Email
« Reply #2 on: August 03, 2008, 08:13:44 »

is there a way to do this without using pipes?  ???
Logged
chitchu
Newbie
*
Posts: 3


View Profile Email
« Reply #3 on: August 04, 2008, 12:14:40 »

chitchu,

Have you considered Pipes? The solution that you are looking for may be Pipes.

Using pipes, ModuleB can send a message though a pipe connected to ModuleA requesting for the data that ModuleB wants. ModuleA can then send the data through another pipe that is connected to ModuleB.

This way, the two modules are decoupled.

Ramanuja.

Thanks Ramanuja.

We already did this appoarch, and was successful.  But I was kind of feeling like it was more of a hack or a quick fix.  So I am wondering, what is the best practice for multicore sharing proxies?

Thanks in advance.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: August 04, 2008, 04:55:53 »

Sharing Proxies between modules is not a good practice.

The main goal of modular programming is to separate functionality into separate 'black boxes'. One module shouldn't be messing with the actors in another module.

Pipes decouples the modules and gives them a way to share data with an asynchronous protocol of your own devising. (See PipeWorks demo)

The other acceptable way for modules to communicate is by exposing interfaces that allow synchronous communication, but the modules must have a reference to each other. (See Modularity demo)

-=Cliff>
Logged
ramanuja
Jr. Member
**
Posts: 17


View Profile Email
« Reply #5 on: August 04, 2008, 09:54:12 »

Cliff,

Is it okay for one module to send a VO to another module? Sending a proxy itself sounds very wrong as you mentioned. I have had this doubt for quite a while.

When using webORB's setCredentials(), we need to pass in the username and password right? The LoginVO that contains this data may be a part of the Shell.

How do I send across these details to a module that wants to set these credentials?

I hope I have stated my problem clearly.

Thanks,
Ramanuja
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #6 on: August 04, 2008, 01:37:17 »

Yep. Sharing a VO (or even a view component that gets hooked into the display herarchy of the main app) is pretty much a necessity in most modular apps.

Put the VO definition in a commonly shared library (a Domain API). You could even send XML that is compliant with a schema that both modules understand.

Options for shuttling the VO, XML or view component back and forth remain as stated earlier: synchronous interface call or asyc messaging via pipes.

-=Cliff>
Logged
chitchu
Newbie
*
Posts: 3


View Profile Email
« Reply #7 on: August 04, 2008, 11:07:51 »

I understand now.  Thank you for the enlightenment.  Very much appreciated.

Some refactoring will be needed.   :-\
Logged
Pages: [1]
Print