kb:bestpractices:codingconventions:style
Table of Contents
00 Style
points marked with [VI-AN] are testable with VI Analyzer
Language
-
English is the default language for
-
filenames
-
variable / control names
-
comments in code
-
German is accepted only for
-
running text in SCC commits
Naming
-
File names are built with spaces between words
-
No CamelCase
-
No Under_Lines
-
No Hy-phe-na-tion
Capitalisation of everything but conjunctions, prepositions etc. (“or”, “and”, “by”, “for”…)Same rules apply to case labels, function names etc.Special VI and Control Types
Append two dashes (
-
-
) and an identifier to the file name of special VI and Control types, egSomething-
-constant.vi
orAnother Thing-
-cluster.ctl
.Type String to append Constant VI -
-constant
Error VI -
-error
Cluster Typedef -
-cluster
Enumerator Typedef -
-enum
Map/Set Typedef -
-map
/-
-set
Basic Conventions
Some of these conventions are supported/enforced by LabVIEW .ini tokens. See the Setup page of the Way Of Working section for more info.
Style
-
Use System style controls for VIs with User Interfaces (enable in Options → Front Panel → Control Style for New VIs)
-
Modern style is an acceptable fallback for SubVIs
-
Terminals of controls and indicators are not to be displayed as icons on the blockdiagram [VI-AN]
-
Right mouse click on icon → uncheck „View As Icon“
-
„Tools – Options → Block Diagram → General“ uncheck option „Place front panel terminals as icons“
-
„Tools – Options → Block Diagram → General“ unceck option “Place structures with Auto Grow enabled”
-
Move error wires to background [VI-AN]
-
QD shortcut for moving to back: Ctrl-shift-J
-
Use VI Connector Pattern default (4-2-2-4) [VI-AN]
-
Exception: 1 In, 1 Out → „flat“ Icons
-
Connector terminals default to “required” (enable in Options → Front Panel → General)
-
Size of front panel / block diagram [VI-AN]
-
doesn't exceed the display (one monitor size)
-
if scrolling is necessary: only in one direction (horizontally or vertically)
-
Use and connect error cluster [VI-AN]
-
Connector Pattern bottom left & right
-
No unexpected behavior should go unnoticed!
-
Follow the dataflow paradigm [VI-AN]
-
Don't use local variables where you can use wires
-
Sequential processing of SubVIs by connecting the Error in- and outputs
-
Stacked sequence structures „hide“ code and are to be avoided
-
Conditional Disable Symbols case sensitivity
-
True value is spelled
TRUE
(all uppercase) -
False value is spelled
FALSE
(all uppercase)
-
Optional: For case structures, if the value wired to the case selector from the outside is NOT used inside the case structure, move the case selector near the top in the middle of the subdiagram label. This will symbolize that the wire is not connected inside the cases
Dependencies
-
Check and tidy your dependencies (project)
-
Try and move as many dependencies as possible into your project repo
-
Leave only files from symbolically linked locations (vi.lib, instr.lib, …)
-
Any VIs or controls that are loaded from a different path than the ones mentioned above will make LabVIEW link statically to those files, which will cause problems sooner or later.
-
Save only what you changed on intention. Avoid “Save all”.
-
For SCC: Commit only files you actually changed.
-
For SCC: Commit in groups of changes (commit often).
-
Separate compiled code from source file for all VIs and libraries
-
VI properties → General → Separate compiled code from source file: Check
-
When LV crashes and recovers files from the auto-saved backup, those recovered VIs don't have the flag set (might be fixed in LV 2020)
File System
-
Remove unused/deprecated/old code (VIs) immediately!
-
tidy up ASAP to avoid propagation, also later on time might be of the essence
-
Keep test VIs outside the project if they are not used by the application
-
Alternative: Make them part of the library they cater to, document etc.
LabVIEW Projects
-
Each .lvproj file may only contain one (1) target with VIs underneath
-
A project for Windows applications or Windows libraries may only have VIs under the “My Computer” target!
-
A project for a real-time application must not have any (!) VIs under the “My Computer” target!
-
See Real-Time Deployment for the reasons behind this rule
-
See SCC Rules for how to handle .lvproj files with source code control
-
kb/bestpractices/codingconventions/style.txt · Last modified: 2024/08/09 08:05 by joerg.hampel
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-