09-16-2010 08:54 PM
HI everyone, I have inherited some code, and have been asked to make it better and cleaner. I am very new to labview. I have core 1 and core 2 under my belt so far and have done a fair amount of research and reading. The code that I have inherited seems to violate two rules of thumb that I have read about; 1. don't overuse variables and 2. Don't use flat sequence structures unless necessary. This code that I have attached seems to do both. I could use some suggestions on where to start with this mess. My first thoughts are to eliminate flat sequence structures, and use an event structure to handle the user interface controls.
09-16-2010 11:31 PM
Inherited code is like a pinata. You never know what you're going to get, and it's almost always something you want to throw out. In your case it's bad all around. Well, starting with an event structure is a good first step. Not sure how this program is supposed to work, but I'd suggest looking into using the Producer-Consumer architecture. The producer part can handle the events and pass off operations to perform (the "data") to the consumer via a queue.
There appear to be several "top-level" programs in the folder, even though the project only calls out XMC_demo4. Are the others ones old and/or defunct versions? If XMC_demo4 is the program that needs to be "fixed", there are a number of subVIs that aren't called by it.
What version of LabVIEW do you plan to use.
Other tips:
Gotta go now. Need to sleep...
09-19-2010 09:54 PM
You make many great points that I shall try and implement. When I am done with my changes, I will repost the corrected code. I am sure it would be nice to see that your help was not wasted. I believe, though, I will have to re-write the application because it seems that to modify the origianl code may be extremely daunting for a newcomer to labview. I have been doing alot of reading and studying of labview code examples and have alot of stuff in my head. Its like I have a whole jigsaw puzzle in my head and I am trying to put the pieces together; it keeps me up at night. I hope my brain can sort all this out before I have my first review in this company that I have recently joined less than a year ago.
09-20-2010 09:50 AM
The best way to start is with a solid architecture. The producer-consumer is an extension of the more basic master-slave pattern. It would be worth reading about the state machine architecture as well. These design patterns make it very easy to write solid code that is easy to modify and add to.
When you have further questions don't hesitate to post back. However, if the question is more LabVIEW oriented, which is what it seems to be with this, you're better off posting in the LabVIEW board, as the question will get far more visibility there.
09-21-2010 09:08 AM
@smercurio_fc wrote:
Inherited code is like a pinata. You never know what you're going to get, ....
And you usually want both a blindfold and a large stick!