10-12-2010 01:57 PM
@Aristos Queue wrote:
But, my opinion, typedef clusters are dinosaurs and the meteor is in the sky.
Well, let's roll with that for a minute. Consider an extremely simple class, for instance your group of configuration settings that have no interaction with one another, and all data members have pure getters and setters that contain no data transformations.
Truly, it is a class that has no differences from a vanilla clustered typedef (except that now we've got mutation history! 🙂 ).
So consider this: it's tedious to create individual accessors for each data member - lots of clicking and lots of files to lug around with SCC. It would be so much nicer to be able to mark individually data members of the Class Data Cluster as "Public Read" or "Public Read/Write" or "Private". This would allow any caller of the class to use Bundle/Unbundle dropped directly on the object wire to access data - all class data doesn't necessarily need to be private! (again, this conversation must have happened before, please link if you know)
Once it's not a PITA to replace typedefs with classes, then I could begin to let go of typedef'd clusters for new designs.
10-12-2010 02:14 PM
I think the Serialization/Deserialization concept is an Idea here: User-Defined Automatic LVOOP Class Conversion Functions.
AQ's response is disheartening: This is an idea already on the LVOOP roadmap, but at this time it is fairly far down the roadmap, time horizon 8 to 10 years. Kudos for this idea might pull it up sooner.
So, let's get it pulled it up sooner.
10-12-2010 02:35 PM
JackDunaway wrote:Once it's not a PITA to replace typedefs with classes, then I could begin to let go of typedef'd clusters for new designs.
Yep. That's the goal. It's still a ways off, but that's the goal.
10-12-2010 03:16 PM
I think that type def'ed cluster (like Action Engines) still will have their niche in a LVOOP world.
If I want to plot data on an XY-Graph, I just use a plain cluster, no type def at all.
If I have a set of related parameters, that neither need methods nor inheritance on their own, I'd make them a type defed cluster and use this as one of the properties of a class with Acessors that accept/return the cluster.
But for sure the meteor for the Clusterosaurus Rex already impacted and the iceage started. Keeping this analogy, we still have plenty of reptiles on our planet.
A definitive niche for all those reptiles is on the borders of our code. Mentioned before was interfacing dll's, more heavily discussed the serialization to disk (the OpenG variant config vi's work like a charm with type def'ed clusters) and I would also add the user interface to this list.
Felix
10-12-2010 07:48 PM
OK, if classes are going to replace typedefs, we need a better language feature for accessing class data outside of the private scope. Chime in over there with feedback.
10-12-2010 08:26 PM
Off the top of my head:
@JackDunaway wrote:
So consider this: it's tedious to create individual accessors for each data member - lots of clicking and lots of files to lug around with SCC. It would be so much nicer to be able to mark individually data members of the Class Data Cluster as "Public Read" or "Public Read/Write" or "Private". This would allow any caller of the class to use Bundle/Unbundle dropped directly on the object wire to access data - all class data doesn't necessarily need to be private! (again, this conversation must have happened before, please link if you know)
Once it's not a PITA to replace typedefs with classes, then I could begin to let go of typedef'd clusters for new designs.
I would love to see this point discuss in greater details - as it has come up before in local discussions, so I have no links.
Additional to this discussion, I have heard for example "It is painful to have to create Accessor methods just to access data in Inherited Classes..."
Obviously there is more overhead/work in using LVOOP but it is worth it.
Using scoped (private) data with subVIs provide data protection, which is one of the great benefits of LVOOP IMHO.
I think its goes against the principle of LVOOP to do what you are suggesting.
Off the top of my head: If you have public data as suggested, I can see that you would lose some benefit of encapsulation - what happens if I need to run some private methods before or after Data Member access? I.e. precheck data in range before exposing.
If this is required then I currently do this in the Accessor Method VI, so this is transparent to calling code.
So if in future something changes and I need to call a private method, and all I had simple bundle/unbundles in my code, I would have to troll through all my code and replace them with subVIs.
Which I could have avoided by using subVIs in the first place.
What about inheritance? E.g. This Accessor always does this to the data before exposing the data...
How would replacing/renaming/changing Data-Members cope?
If I break an Accessor can I quickly go into that subVI fix it (and elsewhere in my Class) and my calling code is protected?
Or am I stuck having to update every bundle/unbundle node in my code - just like I would a type-def?
In 2010, the PN kind of provides this feature - easy access but you need have Accessors created for it.
Maybe you could have a PN automatically available for Data Members when a new Data Member is created?
The developer could have the ability to create a custom Accessor Method VI if it was warranted in the future.
This would maintain a consistent API, that would stand up to changes and not break calling code.
I am very interested to hear other opinions on this.
10-12-2010 08:44 PM
@PJM_JKI wrote:
It is my belief that one should use classes only where there is an overwhelming advantages over not using them.
Why does there have to be an overwhelming advantage? There is a small increase in the time required to create classes that (for me) is more than offset by the time saved when changes are made to the data and the convenience of data safety.
@PJM_JKI wrote:
Quick example. If took over a code written by another developer and I see a cluster, I know how this will be used/accessed all throughout the code. Now, if instead I do see a class, I need to find out a lot of informations before I can know how this is used in any given VIs. This take a lot more brain power since this is essentially adding a new data type that has its own rules and "regulations".
Counter example: If I take over a project that has lots of typedeffed clusters, I have no idea where in the application a specific cluster element is being written or read. Suppose I want to find where the 'Name' field is used. I can't do a search on an 'unbundle Name' node. I have to find all the cluster's calling vis and manually search through the block diagram to see if that element is used. With the common supercluster technique, you can bet it's going to be on the front panel of lots of vis. Since I'm only interested in the Name element I'll spend a lot of time and brain power searching to find those few vis that use it.
Contrast that with a class. If I want to find where the Name field is read I can simply search for instances of 'Get Name.vi.' Easy.
10-12-2010 08:48 PM
JG - great insight. I don't know if you've seen it yet, but let's carry this conversation over to the Idea that specifically deals with data member scope (that Idea was a tangent from this original thread anyhow). Feel free to copy-and-paste your entire comment over there. I'll go ahead and acknowledge up front we could shoot some lethal holes in that Idea, but maybe something good will come of it.
10-12-2010 08:50 PM
@JackDunaway wrote:
JG - great insight. I don't know if you've seen it yet, but let's carry this conversation over to the Idea that specifically deals with data member scope (that Idea was a tangent from this original thread anyhow). Feel free to copy-and-paste your entire comment over there. I'll go ahead and acknowledge up front we could shoot some lethal holes in that Idea, but maybe something good will come of it.
Sorry, I missed you second one whilst typing...
...Done 🙂
10-12-2010 10:19 PM
Daklu wrote:data and the convenience of data safety.
Contrast that with a class. If I want to find where the Name field is read I can simply search for instances of 'Get Name.vi.' Easy.
Unless you're using the new property nodes feature.