Quantcast
Channel: LabVIEW topics
Viewing all articles
Browse latest Browse all 66879

case selector string data type

$
0
0

This is a purely academic question...

 

I have recently started work with a new team at a new company, and one of the first things I noticed about their LabVIEW code was that they very often used strings for case structure selector control.  On other teams I have experience with I have seen the use of enums (a lot), numbers, and booleans.  Only very rarely do I recall seeing strings used much.

 

I always thought (and I guess I thought most people also thought) strings just made things difficult because it is hard to tell just what string might be sent to a case, since any string not explicitly called out in it's own case will use the default case, which is required when using strings. Not to mention type-os, case sensitivity issues, etc.  On the other hand, with enums you can use the "add case for every value" feature, you don't need a default case, all possible received values are obvious, there is no chance of type-os, etc.  I thought for sure I saw this mentioned in the past in the style guide, or one of the classes, but I can't seem to find it.

 

Fortunately, the team lead doesn't force anyone to code this way, so I will just keep using enums, but everyone on this team seems to think using strings is a good way to go, so I now wonder if I have previously been working on teams that did things odd, or is this team doing things odd. I thought this might call for an informal poll, so if any of you don't mind answering:

 

How do you usually control cases structures in your code (particularly enum vs string), and why do you use the method that you do?


Viewing all articles
Browse latest Browse all 66879

Trending Articles