QControl Enthusiasts

cancel
Showing results for 
Search instead for 
Did you mean: 

Choosing Inheritance

Quote from this post:


Alright I have another one for you.  Lets say I want a QControl that works with a Listbox, a Multicolumn Listbox, a Table, or a Tree.  How would you handle that?  I realize you could inherit from the Control class, and then just error if the input wasn't one of those but is there a better way?  I was thinking about making a QControl for each of those control types, and then use a polymorphic VI, which would select the Create, and Close functions.  It seems like a lot of work but I like that method better.  Any other suggestions on how to handle that?


When choosing which class to inherit from you have to consider which properties and methods do you want available to the user of your QControl.  It would work to inherit from the Control class and handle the reference casting between Listbox, Multicolumn Listbox, Table, or Tree all internally in the QControl code but then only the properties and methods available to the Control class would be exposed.

 

I would suggest creating one for each type so that the properties and methods for each type are available.  If you would like to make the API easier by combining the Constructor and Destructor VIs into Polymorphic VIs then that is totally doable.  Polymorphic VIs accept the VI server references as different types and can automatically adapt to the correct type if that option is checked in the Polymorphic VI.

 

One other suggestion might be to encapsulate any shared methods used between the four QControls in a separate "helper" class.  Any methods used by all four QControls should be community scoped with them set up as Friends in the "helper" class.

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



Message 1 of 1
(2,331 Views)