PureMVC Architects Lounge

PureMVC Manifold => MultiCore Version => Topic started by: Sebastian on October 30, 2012, 04:37:50



Title: PureMVC-Improvements: Array to Dictonary or Vector ?
Post by: Sebastian on October 30, 2012, 04:37:50
Hi,

I am currently looking at the puremvc sourcecode and maybe I have some improvements.

For example:

org.puremvc.as3.multicore.core.View.as

Why you are using Array instead of Dictonary?

:
// Mapping of Mediator names to Mediator instances
protected var mediatorMap : Array;

// Mapping of Notification names to Observer lists
protected var observerMap : Array;

// Singleton instance
protected static var instanceMap : Array = new Array();


change to:

:
// Mapping of Mediator names to Mediator instances
protected var mediatorMap : Dictionary;

// Mapping of Notification names to Observer lists
protected var observerMap : Dictionary;

// Singleton instance
protected static var instanceMap : Dictionary = new Dictionary();


And I changed:

:
var observers_ref:Array = observerMap[ notification.getName() ] as Array;

// Copy observers from reference array to working array,
// since the reference array may change during the notification loop
var observers:Array = new Array();


to:

:
var observers_ref:Vector.<IObserver> = observerMap[ notification.getName() ] as Vector.<IObserver>;

// Copy observers from reference array to working array,
// since the reference array may change during the notification loop
var observers:Vector.<IObserver> = new Vector.<IObserver>();

On other places it is the same.

Are there any downsides or good reasons not using these changes mentioned above?

Best regards and thanks for this great framework,
Sebastian


Title: Re: PureMVC-Improvements: Array to Dictonary or Vector ?
Post by: puremvc on October 30, 2012, 09:10:26
Why you are using Array instead of Dictonary?
Because Array is part of AS3 but Dictionary is a Flash class (flash.utils.Dictionary).

One of the primary tenets of PureMVC's design was to use language-only elements, and then the simplest, most common ones. This is what makes PureMVC highly portable. Most languages have Array, but Dictionary (and Vector) are less common elsewhere.

-=Cliff>



Title: Re: PureMVC-Improvements: Array to Dictonary or Vector ?
Post by: Tekool on October 30, 2012, 02:10:58
I think we already dicussed that on an another thread.

If I remember well, here, the problem is that we don't use any array methods. In fact it has to be re-typed to Object if Dictionnary isn't possible. I had too, in other ports I made, TypeScript included.