One of the best places to find reusable code is in your old projects. However, “mining” your old projects for “reuse gems” (sorting through every VI, looking for sparkly little gems of general-purpose code that have immense value) is simply not an effective use of time or energy.
For example, if you were a miner looking for precious minerals, you would wouldn’t roam the countryside digging random holes in the ground. Rather, you would work smart — you would try to identify a geographic location with a very high natural concentration of precious minerals (based on a variety of clues). Guess what? This is exactly how you should mine for reusable code in your past projects. But, where do you start looking and what are the clues that will lead you to those reuse gems?
Here’s the secret:
While writing code, when you identify that you are writing a VI that is generic and has the potential to be reused, save it inside a sub-folder of your project folder called “Reusable VIs”.
If you adhere to this strategy, it will be very easy for you to come back later and find your reuse gems. And, before you know it, you will have what resembles a reuse library. Best of all, you didn’t even have to get your hands too dirty.
Note: As your reuse library grows (which it will if you use the planning techniques described above), you’ll need to start thinking about how to utilize your reuse library on multiple projects and share these VIs with other developers. Make sure you don’t get stuck in the pitfalls of a monolithic reuse library caused by copying your reuse library from project to project or by using the same version of your reuse library on each project. Create a VI Package and install your reuse library in your palettes using VIPM — it’s easy and simple.
I’d love to hear your feedback, so please feel free to leave a comment. For example:
- Do you have a folder in your project where you put new, reusable VIs?
- Do you think that this is a good idea, or do you have a better strategy?