Last month during a discussion at client’s place we were discussing about the good system design and eventually one small thing came to my mind.
As one becomes more experienced LabVIEW programmer and designs better applications, number of case structures in his code dramatically reduces. This may appear baseless but this is what I have observed and verified after that.
As we become better system designers we start focusing on extendability and robustness. We start focusing on dynamic code and here is where Case structures start reducing.
Lets take an example. Say we want to design an application which controls a process by sending commands to a particular controller. The controller can have either serial or Ethernet link.
If a novice user is to program this application he might code some thing as follows

Nothing wrong in it actually. We are looking for the mode in which device is connected in and then select the appropriate case for communication.
However if we think in terms of extendability. This is not a very good code. If tomorrow we get USB or any other interface then we might need to modify our existing code and test everything again. So how about dynamic loading

This is much better because if new protocol support is required then we need to design just new interface. We don’t need to modify anything in our main code.
This is typically how most of the (unnecessary) case structures get eliminated.
Note: if you implement dynamic loading exactly as displayed in this snippet then the code will run much slower. There are well known trick to avoid performance hits. However i wanted to keep things as simple as they can be.
another big (rather biggest) source of case structure removal is adaptation of design patterns. Many fresh programmers don’t use any design patterns and their code is full of nested case structures (4 to 5 nested levels are quite common.) when they start using design patterns nested levels drop down dramatically.