What Are LabVIEW Coding Best Practices?

Updated Mar 23, 2026

Reported In

Software

  • LabVIEW

Issue Details

  • Where can I find LabVIEW coding best practices? My code is getting messy and I'd like to make sure I'm doing things right.
  • I'm new to LabVIEW and my code is inefficient. What are some of the ways that I can improve my code?

Solution

There are many guidelines that can be considered when developing LabVIEW code, depending on your code complexity and purpose.

The following list is an outline of the most common and beginner-friendly considerations, but by no means represents a full and comprehensive list:

 

  • LabVIEW code should always use error wires to force execution flow wherever possible.
  • Execution flow should be left-to-right as much as possible (avoiding backwards wires and up-to-down flow).
  • Avoid unnecessary bends in Block Diagram wires.
    • The keyboard shortcut <Ctrl>+<U> can be used to quickly clean up a highlighted object/wire.
    • Avoid using the clean-up shortcut on the entire VI.
  • Your application should comply with a design pattern. The most suitable design pattern depends on the complexity of your code, but some common architectures include:
  • Local Variables and Global Variables should be avoided unless absolutely necessary.
  • When using Case Structures, define a default case.
  • Use Event Structures to monitor events from the UI instead of polling.
  • Avoid using Sequence Structures unless absolutely necessary. See Determining When to Use Sequence Structures for more information.
    • If you need to enforce execution flow, use error wires.
  • The Block Diagram should fit within the monitor screen without the need to scroll.
  • Avoid duplicate code on the Block Diagram. Duplicates tend to be a good candidate for SubVIs.
  • Avoid unused code.
  • The Front Panel should fit within the monitor screen.
  • The Front Panel should be logically organized, where Controls and Indicators are positioned to reflect the Connector Pane.
  • Avoid using more than 16 terminals on the Connector Pane.
  • Create a meaningful Icon for all VIs. Icons should:
    • Use the standard 32x32 pixels size.
    • Use built-in Glyphs where possible.
    • Use standard text settings.
    • Limit the text in banners to a single line.
    • Ensure contract between front and background colours.
    • Prioritize minimalism - use the smallest amount of Glyphs and text possible to convey the purpose of the VI.
  • VIs should be well-documented, which includes Free Labels on the Block Diagram and a description in the VI Properties window.
  • Custom data types that are used in multiple places should be converted to Type Definitions.
  • Use VI Analyzer to assess the quality the readability of the code.
  • LabVIEW project files should reflect the file hierarchy on disk.
  • Your LabVIEW files should be organized on disk as follows, see Best Practices for Managing NI LabVIEW Applications Using the Project Explorer for more details:
    • All files should be within a single root directory.
    • The application should be divided into manageable logical pieces.
    • Use descriptive naming conventions.
    • Separate top-level VIs from other source code.

Additional Information

Refer to the Related Links below for more detailed and specific guidelines.