01-08-2014 04:21 PM
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.
Solved! Go to Solution.
01-08-2014 04:34 PM
01-08-2014 04:36 PM
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.
01-08-2014 04:43 PM
Thanks guys.
Are there any precautions or recommendations for mixing or adding classes and where how to file/manage them?
01-08-2014 04:45 PM
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.
01-08-2014 04:50 PM
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
01-09-2014 08:06 AM
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
01-10-2014 02:48 AM - edited 01-10-2014 02:49 AM
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
01-10-2014 04:01 AM
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