PureMVC Architects Lounge

PureMVC Manifold => Standard Version => Topic started by: swidnikk on November 02, 2009, 12:15:53

Title: NAME property of Proxies
Post by: swidnikk on November 02, 2009, 12:15:53
I've used PureMVC AS3 Multicore for sometime now and am playing around with C# port.

The Proxy pattern has a public static NAME property with a default value of "Proxy", however after creating an instance of the proxy class (or a subclass) this NAME property is left as its default value.

This means in a command when I want to retrieve a proxy, I must manage my proxy names, where as, if I'm not mistaken, in AS3, the NAME static variable is reassigned in the constructor to reflect a particular proxy instance's given name. In this way I can retrieve a proxy by Facade.RetrieveProxy( MyProxy.Name ).

Is it by design that the static NAME variable is not reassigned in the constructor?

Title: Re: NAME property of Proxies
Post by: puremvc on November 04, 2009, 08:20:25
The NAME variable is not overwritten in the constructor in AS3. Instead it is passed to the superclass (Proxy) where it is set as the proxyName property, which the framework requests from the class by calling getProxyName();

Looking at the C# source for Proxy, I can see it uses three overloaded constructors to allow calling with:
  *  no arguments (constructs with NAME and no data),
  *  a proxy name only (constructs with supplied name and no data),
  *  or a proxy name and an object (constructs with supplied name and data)

This seems ok to me if NAME can be overridden in the subclass.


Title: Re: NAME property of Proxies
Post by: adamczak on November 13, 2009, 02:10:25
If you actually compare the sources of the ActionScript Proxy and C# Proxy, the code for the static NAME variable and the constructors are almost exactly the same (the three constructor overload correspond to the default values allowed in the ActionScript constructor).  The way to typically use a name on the proxy, is that you create a "public new const string NAME" on your subclass with a class specific value, and you use that NAME variable to retrieve or remove proxies.  This is the same usage pattern used in the ActionScript implementation.


Title: Re: NAME property of Proxies
Post by: puremvc on November 13, 2009, 01:10:21
Yep. And this is the way it works with AS3 as well. The NAME on the superclass is just so that if you don't pass anything something gets registered.