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: PureMVC-Improvements: Array to Dictonary or Vector ?  (Read 9676 times)
Sebastian
Newbie
*
Posts: 2


View Profile WWW Email
« 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
Logged

puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>

Logged
Tekool
Sr. Member
****
Posts: 192


View Profile WWW Email
« Reply #2 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.
Logged
Pages: [1]
Print