I would like you to give me some advice on the code below. I have that case structure in my subvi with 10 cases. For each case, only the polymorphic subvi and the indexing code are different (only slightly). Is there a way to further modularize it (one subvi for each case)?
Slightly may mean one thing to you and another to someone else, and in either case it is difficult without seeing the code. You will either need to post your code, or show a couple of more cases.
One SubVI for each case? That is only a cosmetic change and since your BD is not so big I don't know why you want that. On the other hand, one SubVI for all cases (or several) would be just what the doctor ordered. For this, we need to see more code.
Final note from picture: For very interesting reasons you may want to get into the habit of putting your array controls and indicators on the top level diagram (not inside the case structure). In some cases, not necessarily this one, it will save you needless data copies. Just a good habit to adopt, mostly applies to times when you are passing data through, but why think about it? I think searching for "Clear as Mud" explains a bit more (ironically).
Just a thought, what if the sub vi also does the type -> variant? If so, you can wire the Type to the sub-vi and skip all the cases (maybe) as you'll just add variants to the array.
Would that work?
BTW, why would putting the control/indictor outside case structure save memory?
In this case it won't make a difference since you are not passing through data. When you are working with arrays (or strings) or other large data structures it is useful to pass data through subVIs as opposed to branching wires. When you pass through data, the compiler needs to know if the operations can be done in-place, and if there is even the slightest doubt, it guesses no and makes a copy. One pattern the compiler will recognize is data being passed through when the control and indicator are on the top level of the diagram (not in a case or loop structure). If one or the other is inside the case, a copy is made. My point is that it is almost always a good idea to put controls on the top level, seeing that control and indicator inside your case structure rang a bell with me. A similar idea holds with loops, unless the control is meant to be read during the loop, it should be placed outside. Sometimes a little extra wire can save a lot of time and memory. (Again, more of a general statement not a comment on this particular VI).
After a few reads of the Clear as Mud thread and some headscratching it makes sense, in the meantime it is better to build good habits and good style.