Testy Posted September 12, 2013 Report Share Posted September 12, 2013 I am a fan of statically typed programming. I'm also a fan of message passing to share data between parallel sections of code. Because of this, I wish this idea would get more traction: http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Wire-Class-To-Case-Selector/idi-p/1457642 And here's why- Suppose I have modules in my application that broadcast messages using a User Events. Any other code module can register for these events and receive the messages. But if these messages can carry different data, I have no pretty, typesafe, way of guaranteeing at compile time that the message carries the appropriate type of data. I could dynamic dispatch on a message Do.vi, passing in a class that inherits from some class the Do.vi calls a dynamic dispatch vi of. For each event registration I have to create another class. Including interfaces in LabVIEW OOP would alleviate this. However, I think the above linked idea provides a cleaner implementation. Another option I have is to attempt to downcast the parent message class to all of its children, and do something once a downcast is successful. This works fine, but if there are a lot of child messages this design pattern becomes large. The linked idea would achieve this in a much more compact, readable way. I'd also like case classes in LabVIEW - classes with no private data or methods, that include child classes beneath them in tree fashion in the project explorer, making it very clear what possible concrete data types can manifest at runtime. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.