Class Comparisons Examples

Few days ago I was playing around with LabVIEW trying to raise some use cases for making class comparisons, I mean, equal comparisons.

I went further and decided to play around with some type casting (to more specific node and preserve run time node), so it was when I decided to stop, and I got back to single equal comparisons, and leave this subject for other post.

Equal Comparisons

Sometimes you just need some equal comparisons of classes objects. If you are not used to OOP in LabVIEW you would think that it is just comparing two wires from same color, right?

Not even close.

Classes have to be identical in type and values inside (object properties) to be considered equal.

I put some examples in one of my Gitlab Projects, but I think they can be more ways of doing it. To create comparisons and assert results I used Caraya Unit Test Framework, which has just released its new version 1.2 (Great job François).

So, if you want to add to this Class Comparison example, please create a merge request

Casting Classes

Often casting type functions are used for comparisons, most hierarchical comparisons, but they are often misused. I thought of including some examples of using the “To more specific/generic node” or the “Preserve Run-time Class node”, but the explanation of how it can be used for that is a bit more complicated, and I avoided to get into this discussion, because it is a topic for another post.

Also, there are many of those discussions in NI Forums and Lavag. You feel free to check it out, or you can read about the help in the functions or LabVIEW Documentation Explanation.

Code Available

I made this comparison code available, so if you want to contribute or make a suggestion, feel free to open an issue and a merge request.

Of course, I used LabVIEW Community Edition 2020, because it is a Community Code.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s