LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

control naming scheme

Hello All,

I have been using LabVIEW for several years now, and have some quite tight self-imposed coding standards that I follow.

However, the one thing I can never seem to keep consistent in my code is naming of controls (typedefs and actual user controls). Sometimes I think a capital letter for every word looks neater, sometimes I prefer the minimilist approach of using no capitals unless it is an abbreviation. Normally I use a capital letter if a tydef is a complex structure (i.e. a cluster) and a small letter if the control is a primitive function.

I have tried looking at NI code, but they also seem to mix and match styles. Smiley Indifferent

The Style Guide by Bloomy is quite good in most respects, and it seems to prefer the Capitilisation Per Word Variable Naming Approach.

This problem actually can be extended to VI naming and visible front panel control naming.

Does anybody have a document describing LabVIEW specific control/VI naming conventions, or can any of the other veterans shed some light on their standards, I would be very interested to hear.

Thanks!

0 Kudos
Message 1 of 11
(4,191 Views)

Hi nrp,

I have been having a browse through the LabVIEW style guide which is the document produces by NI on matters like these and it doesn't really mention much in the written part but if you skip down to the checklists it does mention this.

First it says that controls should be named with consistent capitalization.  So I guess its trying to say just dont have capitalization all over the place!  I personally tend to always capitalize and looking through some of the NI course manuals they also do this.

It does also say in the checklist for VIs that the names should have the first letters capitalized.

Hope that is the sort of thing that you were looking for.

James Mc
========
Ask me about Rust & NI Hardware
My writings are at https://www.wiresmithtech.com/devs/
0 Kudos
Message 2 of 11
(4,140 Views)
Thanks James,

After reading your post I took a quick look at the contents of my LabVIEW 8.5 vi.lib directory. What a mess! The naming conventions of the NI VIs is totally non-standardised, some have Initial Letter Capitilisation, some have NoSpacesBetweenWords, some have hyphens-between-words-and-small-letters, some have spaces between words etc etc.

I understand some of these VIs are quite old, but even looking at a recent API, DAQmx, there is inconsistency in the VIs regarding control naming (some controls have no capitilisation some have First letter etc).

If NI cannot stick to their guidlines how is there hope for the rest of us?
0 Kudos
Message 3 of 11
(4,126 Views)

You have to look at what you described as an example of "how NOT to do it" 😉    When leading a software team, the Manager or Team Lead or SW Architect has to set some rules which include standardized naming convention, otherwise you end up with what you witnessed. 

The naming convention must be adhered to, in order for it to work.  The difficulty is to enforce it. 

R

0 Kudos
Message 4 of 11
(4,122 Views)
The trouble is, I am the manager, team leader and sw architect in my small company and have no formal advice other than habits built up over several years of doing it wrong and trying to correct it.

I was hoping there was some documentation floating around which could help me figure out how to standardise, in my situation enforcing it is the easy bit.
0 Kudos
Message 5 of 11
(4,120 Views)
I would have to agree that in general it doesn't matter as long as you select a single convention and stick to it.
 
In general, go for readability - I would suggest using full words with spaces. You can also use a capital letter for each word or use just one or not use them at all. Either way is fine, and I don't think you should compatibility issues with any platforms any more.
 
If you have a default value, append it to the control name in parentheses. Try using standard terms and a standard structure (e.g. verb-noun), etc.
 
Try to make the control name describe what its value means. This isn't always easy, but if you're not afraid of long names, you can usually do this.

___________________
Try to take over the world!
0 Kudos
Message 6 of 11
(4,103 Views)
Yes, thats mostly how I do it now regarding naming of VIs (A Space And A Capital.vi)

The verb-noun is the one that catches me out most often, as its quite easy to get this swapped around.
I am still undecided about this (verb-noun or noun-verb). Say you have a several controls all relating to the same noun, then to me the noun should come first as its a logical grouping (in an event structure or something)

An example of this would be in object oriented programming you would say pump.speed = 50

But, I bet there are many counter examples to this...

Thanks for all your input everyone!
0 Kudos
Message 7 of 11
(4,096 Views)
I started a reply yesterday and then got pulled away and did not post it, losing quite a bit of typing and thought. I guess I need to stay focused.

Some things I try to do:
1. Make sure each control has a unique Label. If you do anything with programmatic access via the panel reference and the Controls[] property node, unique names make things much easier. If the UI text should be the same for multiple controls, use Captions.

2. I prefer at least first letter capitalization. error in (no error) is quite annoying.

3. Unlike tst I tend to dislike putting the default value in parentheses. Two (or more) levels of captions would be really nice here. Then the text describing the default value or the units could be placed in a different location from the caption.

4. Like tst the label should be meaningful.

Lynn
0 Kudos
Message 8 of 11
(4,093 Views)
The default value in parentheses is for controls in subVIs. In those cases, the control is rarely displayed to the user and you can see the default value in the context help window or when you hover over the input. This also allows you to tell required and non-required inputs apart.

___________________
Try to take over the world!
0 Kudos
Message 9 of 11
(4,086 Views)
Thanks for the clarification.

Lynn
0 Kudos
Message 10 of 11
(4,078 Views)