Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
August 16, 2017, 02:43:07 PM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: PureMVC-Improvements: Array to Dictonary or Vector ?  (Read 3401 times)
Sebastian
Newbie
*
Posts: 2


View Profile WWW
« on: October 30, 2012, 04:37:50 AM »

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?

Code:
// 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:

Code:
// 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:

Code:
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:

Code:
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: 2870



View Profile WWW
« Reply #1 on: October 30, 2012, 09:10:26 AM »

Quote
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
« Reply #2 on: October 30, 2012, 02:10:58 PM »

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
Jump to: