This is a web application based on actionscript 3.
I have all of my modules enumerated in a class, but I never know which modules actually come from database.
Let’s say I have 20 modules in my application, but the user only has access to 10 of them. All I get are 10 strings from database (the module names) whenever the user clicks a module this string goes through the twenty else if statements until it matches the enumerated value and then it is displayed on screen.
Is there a way to optimize this?
The modules are not flex modules per say, they are just lazy instantiated components.
You’ve got a key and you’re trying to match it to a particular module using ifs, this is a key-value problem which should be solved by a dictionary or hashtable. Not familiar with Actionscript, but it must have dictionaries or hashtables. Does it have polymorphism or is it even strongly typed? Ideally you can put the databases string key into the dictionary as the key, and the associated module in as the value, but this may require the modules use a base type if Actionscript is strongly typed.
8