LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reusable Code in LV.

Hi All,

 

What do we mean by Reusable code in LabVIEW and creating reusable code in LabVIEW.

 

Creating Reusable code means code should have high cohesive, low coupling, scalable,  and other software engineering rules or how to create reusable code in LV.

More explanation will be helpful.

 

Thanks

0 Kudos
Message 1 of 27
(4,297 Views)

@LV_COder wrote:

Hi All,

 

What do we mean by Reusable code in LabVIEW and creating reusable code in LabVIEW.

 

Creating Reusable code means code should have high cohesive, low coupling, scalable,  and other software engineering rules or how to create reusable code in LV.

More explanation will be helpful.

 

Thanks


I will take quick stab at that question.

 

Reusable - Code that can be used in other programs aside from the program for which it was originally developed. Example: A gear that was developed for one machine may be used in another macihe.

 

 high cohesive - The code structure organization and presentation (the API) resembles the system it is intended to support. An expert in the system being controlled should be able to quickly recognize the structure.

 

 low coupling - the dependencies of the reuse code on other components is limited or non-existing. Example: A DAQ module that depends on the GUI it supports is highly coupled. One that has no need for any information about the GUI has low coupling.

 

scalable - This tem speak to the attribute of being able to increase the number channels, components that are integrated into the system It addresses not only how difficult it is to increate the count but alos the impact it may have on performance.

 

I am not a software type by education, but that I my first thoughts on those terms.

 

Ben 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 27
(4,291 Views)

Steve Watts is the coauthor of 

 

A Software Engineering Approach to LabVIEW Development. 

 

Steal a copy 😉 

 

I've had so many hard copies of that book "walk away from my cube" that Swatts, as he is known around here, has comped me an e- volume. 


"Should be" isn't "Is" -Jay
Message 3 of 27
(4,287 Views)

Thanks,

 

It means that all the LabVIEW design pattern and architecture comes in the definition of Resuable code?

If the code follow basic guidelines like low coupling, maintable, scaleable reabable then it's easy to reuse this type of code?

 

Hemant

0 Kudos
Message 4 of 27
(4,279 Views)

Not much to add from Ben's response.  But if you want good examples of reuse code, look at OpenG and MGI toolkits (free on the LabVIEW Tools Network).

 

But what I end up doing a lot is making libraries of code that accommodate a very specific thing.  For example, I have a library specifically for communicating with devices that use SPCI.  I have reused that library many many times for different instruments I have had to interface with just in the last year.  Trying to keep things generic is hard sometimes, but the reuse is worth it.  Just plan far ahead when you go down this path.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 27
(4,272 Views)

@crossrulz wrote:

Not much to add from Ben's response.  But if you want good examples of reuse code, look at OpenG and MGI toolkits (free on the LabVIEW Tools Network).

 

But what I end up doing a lot is making libraries of code that accommodate a very specific thing.  For example, I have a library specifically for communicating with devices that use SPCI.  I have reused that library many many times for different instruments I have had to interface with just in the last year.  Trying to keep things generic is hard sometimes, but the reuse is worth it.  Just plan far ahead when you go down this path.


I design even the little engineering tools I make with scalability and re-usability in mind because I've never known an engineering tool to stay an engineering tool for long.  (Or maybe it's just me, because my tools are so easy to use and build on that everyone wants to integrate it into their projects as a full-blown module.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 6 of 27
(4,261 Views)

@LV_COder wrote:

Thanks,

 

It means that all the LabVIEW design pattern and architecture comes in the definition of Resuable code?

If the code follow basic guidelines like low coupling, maintable, scaleable reabable then it's easy to reuse this type of code?

 

Hemant


I think you are over complicating this, reusable code means just that, code that can be reused...

 

Here is a very simplified example. I have a program that monitors a grid tied solar inverter. I graph the amount of power bought and sold, array power, solar irradiation, battery charge voltage and current... etc...

 

Anyway I need to clear and reset my graphs X-Axis to the next day, every night at midnight.

 

No problem, setting the X-axis to display time from Midnight to Midnight just takes this.

111222Capture.PNG

But wait... I need to do that everyday at midnight, and when the program is started, also I need to reset eight different graphs X-axis the same way... and I might want to do this again someday...

 

That's where reusable code comes in, I make this a Sub-VI and put it in my User.lib directory. 

22222Capture.PNG

Now whenever I need to set an X/Y chart axis from Midnight to Midnight I can just drop in this VI.

 

Over time you will find yourself writing little routines that do the same thing over and over again. Eventually it will dawn on you to make these into a Sub-VI and save it in your User.Lib directory so you can use it again next time without having to reinvent the wheel. 

 

 

 

========================
=== Engineer Ambiguously ===
========================
Message 7 of 27
(4,253 Views)

I will offer these two images to try to illustrate what I think is considered highly cohesive.

 

This image shows the high-level relationship of software to the hardware used in a wind-tunnel application.

Design.png

 

This image show the VI-hierarchy of the LV code.

 

Hierarchy_1.png

 

If someone knows the physical system they can understand the software version.

 

The DAQ Engine shown in that image has been in development for many years now and was recently deployed to support 300 I/O points spread across (4) cDAQ chassis.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 27
(4,235 Views)

Is using a ancester class data or method in child class can also be a example of reusing code?

0 Kudos
Message 9 of 27
(4,175 Views)

@LV_COder wrote:

Is using an ancestor class data or method in child class also be an example of reusing code?


It is different in some senses, but this form of reuse is a major reason OOP became popular in any language.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 27
(4,148 Views)