PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: jimrobson on January 15, 2008, 06:15:08



Title: Need for getProxyName method
Post by: jimrobson on January 15, 2008, 06:15:08
What is the purpose of the getProxyName method? Admittedly, I'm still a PureMVC n00b, but at this point I don't envision using this method very often. What would be the consequences if I were to write my proxy classes without implementing IProxy - and thereby omitting this method? I would like to write proxy classes that extend Notifier but do not implement IProxy. Would this be wrong, and if so, why?


Title: Re: Need for getProxyName method
Post by: Rhysyngsun on January 15, 2008, 06:58:03
getProxyName is used internally in the view in the registerProxy method to get the name of the proxy, however, this functionality is defined in org.puremvc.patterns.proxy.Proxy. Take a look there and as long as you pass the proxy's name to the base class's constructor. The only time you would really need to use getProxyName is if you were implementing your own custom implementation of the Proxy class or aren't passing the proxy's name to the base class constructor.


Title: Re: Need for getProxyName method
Post by: jimrobson on January 15, 2008, 08:06:07
@Rhysingsun - Thanks for the reply.

I looked in    org.puremvc.core.view.View, and I don't see a registerProxy method.

Your answer seems to presuppose that I plan to extend Proxy, but I don't. What I'm suggesting is that I would like to bypass IProxy altogether (Proxy implements IProxy).


Title: Re: Need for getProxyName method
Post by: puremvc on January 15, 2008, 08:09:27
That's the Model calling the method not the View. But just the same, its used internally to find out the name of the Proxy instance at registration time.

The reason its needed (as opposed to checking the oft used NAME constant)  is multiple instances of a given proxy may be instantiated, in which case you may need to return something other than that constant value.

-=Cliff>


Title: Re: Need for getProxyName method
Post by: jimrobson on January 15, 2008, 08:11:19
@Cliff -

Thanks! I found it in the Model while you were posting your reply - but I appreciate your explanation.

-Jim


Title: Re: Need for getProxyName method
Post by: puremvc on January 15, 2008, 08:14:55
You may feel free to implement IProxy rather than extend Proxy, but by the contract of the IProxy interface you will still need to implement this method.

Proxy itself has little to it. Why would you feel the need to implement IProxy rather than extend Proxy?

-=Cliff>


Title: Re: Need for getProxyName method
Post by: jimrobson on January 15, 2008, 08:19:56
I want to implement IProxy directly because I don't have a use for getData or setData.