User | Kudos |
---|---|
8 | |
3 | |
3 | |
2 | |
2 |
I have only recently started using LVOOP but one shortcoming in my opinion is the inability to override the Equality and Comparison operators.
In other object oriented languages one can override the Equality operator, thereby specifying when two objects are to be considered equal. This is very helpful for using built-in search algorithms.
In LabVIEW two objects are considered equal if all of their fields are equal, just like with clusters. Now say one has a class User with the properties ID, Name, and Password. If I want to search an array of User objects to see if a given ID already exists, I have to use a for loop to run through all User objects and compare the IDs. It would be much easier if I could override the Equality operator and set it to just compare the IDs and disregard the rest. This way I could now simply create a new User object with only an ID and then use the Search 1D Array function to find any object with the same ID.
The same goes for the Comparison functionality which is useful for using built-in sorting algorithms.
I know this is probably opening a much bigger can of worms than I can imagine and as a way around it one could always create a UserList class that stores internally a 1D array of all IDs, which could be used to do the searching. However, in the future it might be nice to be able to override some if not all operators.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.