PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: nilsm on January 25, 2008, 05:18:55



Title: check if object registered
Post by: nilsm on January 25, 2008, 05:18:55
Hi all,

I'm quite often faced with having to check whether a proxy of a particular type has already been registered.

For example, different parts of the application can embed a shopping module, which initialises its own proxies. If the proxies already exist in the Facade, I don't re-create them.

At the moment I've added methods to my Facade implementation:

hasProxy(name:String):Boolean
hasMediator(name:String):Boolean

but that requires casting the 'facade' property, so it creates an unwanted dependency in the commands.

Is there a chance that such methods could be added to future iterations of the framework?

Maybe there is also a more efficient way to implement as a native part of the framework rather than attempting to retrieve the object and checking whether the result is null.

Does anybody have any thoughts or other suggestions?

cheers - Nils.


Title: Re: check if object registered
Post by: puremvc on January 25, 2008, 06:49:50
What is wrong with casting the Facade in your Command?

It seems reasonable enough, to add to the framework, though. I will consider it.

-=Cliff>


Title: Re: check if object registered
Post by: nilsm on January 25, 2008, 08:03:06

I guess there's nothing 'wrong' with it - it just means that the command becomes dependent on a particular Facade implementation. I really like the use of interfaces in PureMVC and would prefer not to have to break them here.

cheers - Nils.


Title: Re: check if object registered
Post by: puremvc on January 29, 2008, 11:24:59
Nils,

I'm naturally resistant to suggestions for change, since the goal is to push this thing to a stable point and let it rest. But in this case, you're absolutely right - these methods should be a part of the framework.

I've added hasProxy, hasMediator and hasCommand methods to the Model, View and Controller respectively. The Facade, of course gets all three methods. All the interfaces have been updated, and it is now in 2.0 and the corresponding new unit tests all pass.

-=Cliff>


Title: Re: check if object registered
Post by: nilsm on January 30, 2008, 02:59:50
Much appreciated - thanks!

- Nils.