CLAD Software Development Best Practices 4 — Questions and Answers
Question 1: What is the recommended way to document a subVI's purpose for other developers in LabVIEW?
- Add a comment label on the front panel
- Fill in the VI Properties > Documentation section with a description (Correct answer)
- Place a string constant on the block diagram
- Use the VI's file name as the only documentation
Correct answer: Fill in the VI Properties > Documentation section with a description
The VI Properties Documentation field is the standard location for VI-level descriptions visible in Context Help and the VI Analyzer.
Question 2: Which LabVIEW coding practice helps prevent 'spaghetti code' on the block diagram?
- Using as many nodes as possible on a single diagram
- Breaking complex logic into well-named subVIs and keeping diagrams small (Correct answer)
- Using sequence structures to order all operations
- Routing all wires through the center of the diagram
Correct answer: Breaking complex logic into well-named subVIs and keeping diagrams small
Encapsulating logical units into named subVIs keeps each block diagram small and readable, similar to functions in text-based languages.
Question 3: In LabVIEW, what is a 'functional global variable' (FGV) and what problem does it solve?
- A global variable that can store functions as data
- A single-loop subVI that uses uninitialized shift registers to store state in a thread-safe way (Correct answer)
- A global variable that is read-only at runtime
- A variable shared between multiple LabVIEW projects
Correct answer: A single-loop subVI that uses uninitialized shift registers to store state in a thread-safe way
An FGV uses an uninitialized shift register inside a subVI to hold state, providing controlled, single-access-point data storage that avoids race conditions.
Question 4: When reviewing LabVIEW code for performance, which issue most commonly causes unnecessarily high CPU usage in a loop?
- Having too many subVIs
- Missing a wait function, causing the loop to spin as fast as possible (Correct answer)
- Using too many controls on the front panel
- Having error wires running across the diagram
Correct answer: Missing a wait function, causing the loop to spin as fast as possible
Without a Wait or Wait Until Next Ms Multiple function, a loop consumes 100% of a CPU core by executing as fast as possible.
Question 5: What is the advantage of using LabVIEW's 'built application' (.exe) for deployment rather than shipping source VIs?
- It runs faster than source VIs
- It protects intellectual property and does not require LabVIEW Development environment on the target machine (Correct answer)
- It removes the need for the LabVIEW Runtime Engine
- It automatically installs all required drivers
Correct answer: It protects intellectual property and does not require LabVIEW Development environment on the target machine
A built executable hides source code and only requires the free LabVIEW Runtime Engine on the target machine, not the full development environment.
Question 6: Which practice is most important when committing LabVIEW VIs to a version control system (VCS)?
- Saving VIs in source distribution format (.llb only)
- Saving VIs as individual files (.vi) and optionally using LVCompare for diffing (Correct answer)
- Checking in only the built executable
- Avoiding version control because binary VI files cannot be diffed
Correct answer: Saving VIs as individual files (.vi) and optionally using LVCompare for diffing
Saving individual .vi files allows VCS to track each file, and tools like LVCompare enable visual diff of LabVIEW block diagrams.
Question 7: In LabVIEW software design, what is the purpose of separating 'model,' 'view,' and 'controller' concerns?
- To meet LabVIEW licensing requirements
- To isolate data/logic from UI so each can be modified independently (Correct answer)
- To reduce the number of subVIs in a project
- To allow the application to run on Real-Time targets
Correct answer: To isolate data/logic from UI so each can be modified independently
Separating model (data/logic), view (UI), and controller (event handling) makes each layer independently testable and maintainable.
What is the recommended way to document a subVI's purpose for other developers in LabVIEW?