06-03-2014 10:37 AM
I'm curious. I am a kind of OCD - and LabVIEW REALLY feeds it - and I tend to want to put related things into clusters, which isn't a bad thing, really. But a lot of the things I incluce are already clusters, so there are quite a few levels of unbundling. The question is, where is your tolerance between the need for organization and the pain of having huge unbundle by name nodes? I try to make the labels simple and use captions wherever possible, but it still leads to some nasty unbundle by names, even if I unbundle directly instead of one level at a time.
If I let my tendencies run amok, I would end up with one big cluster of everything.
06-03-2014 10:40 AM
Have a look into LV Classes. Encapsulation is a great aspect of them, and using the access scope properly can enforce proper control over data mutation.
06-03-2014 10:48 AM
I can already hear certain people: "What are clusters? Why aren't your using OOP?"
Personally, I usually have very few things in my clusters. Usually a command with data. Anything more complicated than that is usually not found in my code.
If things were going to get big and complicated, that is where classes come into play and make life simple.
06-03-2014 10:50 AM
@yenknip wrote:
Have a look into LV Classes. Encapsulation is a great aspect of them, and using the access scope properly can enforce proper control over data mutation.
Sure, but the flip side of things. I don't think every cluster should become a class.
Cluster creation really just depends on the developer. Not too many, not too few. If things can be organized into groups, and those groups are commonly used in subVIs, by all means make a typed cluster. There are plent of times where I have clusters of clusters, where both clusters are typed. But if I know my data is only used in one subVI and not shared, I likely won't group it into a cluster.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-03-2014 10:59 AM
There are very few places I would use a cluster over a class.
Organising things into groups which use a common typedef cluster, is pretty much the definition of a methods of a class.
Nested clusters invariably lead to a hierarchical class based data structure. You can also avoid nested Cluster.SubCluster.Data bundle/unbundle operations by just calling a parent getData method on the child class.
Lastly, as I mentioned, is the access restrictions. Allowing access the whole bundle / unbundle data of a cluster is bad practice.
06-03-2014 11:02 AM
Didn't know this would lead to a war between factions. By all means, though - please continue. It's a very interesting discussion.
06-03-2014 11:06 AM
@billko wrote:
Didn't know this would lead to a war between factions. By all means, though - please continue. It's a very interesting discussion.
No no no. It's not a war 😛
My background is in C++, so I came to LabVIEW with (what I consider) a strong understanding of objects, pointers, and memory allocation. Classes and abstraction is how my brain works.
06-03-2014 11:14 AM
Interesting you should ask....
The current project involves finishing a system originated by another developer where I have wires that I can hover over ON MAIN.VI with the wiring tool and my screen is not tall enough for the help window.
This is a sign that the system was designed with poor abstaction, no data hiding, and zip for encapsulation. LVOOP can useful but, simply replacing "Clustersaurus" with "God Object" does not remove the "Code Smell."
The links should give you a place to start rethinking how to apply OOP programming principles in LabVIEW even if you don't need LVOOP to apply those principles.
06-03-2014 11:17 AM
@billko wrote:
Didn't know this would lead to a war between factions. By all means, though - please continue. It's a very interesting discussion.
I'm used to listening to both sides. It can get fun listening to a bunch of CLAs argue over things like this.
In general, I have found those with a CS background like OOP while those with an engineering background do not and therefore work with clusters. Though I am an Electrical Engineer, I find myself moving towards the OOP here and there. It depends on my application.
06-03-2014 11:19 AM
LOL I meant a friendly war. 🙂
Well, it's all about evolution, you know? Learning something then applying it.