LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Normal" code and OOP code in the same project

Solved!
Go to solution

Hi guys,

 

Have large existing application written in ordinary dataflow code.

 

Was thinking of adding a new module but writing it in OOP - in order to learn.

 

Is it possible to add OOP code to existing project?  If so, is it a good idea or not?  What sorts of things do I need to be aware re. mixing of code types??

 

Thanks.

0 Kudos
Message 1 of 9
(3,313 Views)

Hi battler,

 

it's possible to add OOP to an existing project.

 

And you always start with the first OOP class...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(3,306 Views)

They aren't different code types, it's all still LabVIEW. You can drop a class into an existing LabVIEW project with no consequences regarding object-oriented versus non-OO code.

Message 3 of 9
(3,305 Views)

Thanks guys.

 

Are there any precautions or recommendations for mixing or adding classes and where how to file/manage them?

0 Kudos
Message 4 of 9
(3,297 Views)

I can't think of any precautions. I like to put each class in its own folder. If the class contains a lot of files, you can organize them further. I also like to put each child class in a new folder inside the folder of its parent, because it makes it easy to keep track of inheritance, but that's just my convention and I don't know if others do the same thing.

Message 5 of 9
(3,293 Views)

If you are getting started with OOP there are a number of good tutorials out there, if you have SSP and a bit of time, take a look at our self paced online training. It includes a number of courses, ranging from beginner to more advanced and includes an OOP course.

 

If you are coming from a traditional OOP language (such as C++) background, I would recommend taking a read through this article - LabVIEW OOP - The Decisions Behind the Design. It will help with understanding how OOP works in LabVIEW. Good luck! What nathand said is true, OOP works almost the same as any other LabVIEW code and will integrate no problem. The big differences come at an architecture level when you are designing the system for OOP vs non OO.

 

Hope that helps!

 

Jeff Peacock 

 

Product Support Engineer | LabVIEW R&D | National Instruments 

Message 6 of 9
(3,290 Views)
Solution
Accepted by topic author battler.

LVOOP is natural extension of type-def clusters in libraries, so it has no issue mixing with "regular" LabVIEW code.  The only precaution I recommend is the following:

 

Class libraries always load all their contained subVIs (called "methods" in OOP-speak), and standard LVLIB libraries always load all contained libraries (including class libaries).  This "one thing loads so everthing loads" behavior can be a domino effect through your project, with all sorts of unneeded things loading.  To avoid this, be cautious about putting classes inside libraries, and dont always put subVIs in classes if they don't need to be (I often have a regular library to hold "support" subVIs of a set of classes.

 

-- James

Message 7 of 9
(3,228 Views)

Mixing OOP and normal code is a non-issue, it works well. If you want the OOP to be reference based instead of value based you can take a look at the G# addon, available in the VIPM. This also includes a nice debugging tool which'll show object content in a live system.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 9
(3,163 Views)

Hehe, i find discussions like this very funny, esp. if titled like this thread.

When just reading the subject, one can get the impression that LV-OOP is "abnormal", maybe even in the context of "degenerated".... 😉

 

I hope that all readers are now aware (because of really good answers in this thread) that LV-OOP is a core functionality of LV now and is "normal" just like "traditional data flow programming".

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 9 of 9
(3,152 Views)