There’s been a recent discussion between a LabVIEW Product Manager and the LabVIEW Champions on example code I’ve been interested in. The Champions had a lot of great points, there are regular meetings and a private discussion forum for communication, and I wanted to expand on a few of the things that come to my mind and see what others think.
Purpose of Examples
I think of two primary goals of an example. The first is get people up and running with a task they’re starting and the second is to teach people about best development practices. Examples as templates should also demonstrate common applications or needs in applications that people can use as a starting point and customize.
The Right Way or the Fast Way
One specific example used by a LabVIEW Champion got me thinking. Let’s say I want to have my application do something after I click on a button. The traditional way to do this in LabVIEW was to use a while loop and detect a value change on a button. This approach is often referred to as “polling” and it can eat up your processors since the while loop is continually executing and reading the value. When the Event Structure was introduced it provided a much better way where we essentially wait for interumpts from the OS so you’re not just spinning processor cycles polling the current value of a control.
Ideally you should use an Event Structure, you application will respond better and the performance of your application and machine should improve over polling. We do though need to keep in mind that some people are just looking to perform a quick and dirty task where using polling is sufficient and faster to write. Many people transition from this to using that code in a larger application and then the polling approach can break down.
In this case I would want any example that uses polling to call out the pro’s and con’s with polling and mention the event structure as the “right” way and ideally provide a link to that example.
Newer Versions of LabVIEW Introduce Better Ways to Do Something
The event structure is a good example of something that wasn’t in LabVIEW at one time. When it was introduced it provided a better way to develop interactive user interfaces. We should really do something with those older examples shouldn’t we? On Developer Zone we do list the version an example is written in but that doesn’t really inform people that there are features in a newer version, one you may be using, that provides a better way to do something.
Improving Examples in LabVIEW
Improving examples shouldn’t just be about creating more example code. I should ideally be about updating existing examples and in some cases deleting or removing them. Examples are installed with LabVIEW and are available on NI Developer Zone as well as other community sites. The LabVIEW R&D feature specification process does have a section titled “Examples Impact”. I’m going to work with Todd, the product manager I mentioned earlier, to revisit what that sections goals should be. In addition to what examples we need to create, things like what examples need to be updated or obsoleted should be considered. There are some challenges to this process as far as how to manage it and track the use of features in examples but those are details, the overall goal should come first and we should find something we can do today and define what we need in the future.
If you have any other things you’d like to see in examples or LabVIEW to help get you up and running as well as develop your applications please share your ideas by commenting on this post, I’ll be sure to catalog them and share them.