‎10-27-2017 03:55 PM - edited ‎10-27-2017 03:56 PM
Is there a way to create parent class from child class? (yes, backwards from norm). I created a class, lets say Triangle. Some time later, much later, when refactoring my code, I had a need for a Square class. Now at this point it's obvious I should have created a Shape parent class and derived the child classes Triangle and Square from it. But this is a very simplified example which looks rather obvious that I should have created a Shape class from the start... but hindsight is 20/20 they say, and in my more specific case you couldn't have even imagined that I would have needed to.. and here I am. Thus my question: is there and easy (any?) way to create parent class from child class? Note that I do have and am using LAVA- Create Child Class Project Tool, so that make the task easier.
https://lavag.org/topic/15390-create-child-class-project-tool/
‎10-27-2017 05:28 PM
With that premade tool it's probably not possible.
However, if you have a project window open, right-click a class file and go to Properties, then the Interitance tab, then click Change Inheritance, you can change the parent class to any class in memory so long as it isn't currently defined as a child of the class you're editing.
The actual act of making the classes work is up to you, with all the override VIs set up just right. If you have both classes open in the same project you can move VIs from one to the other, though you may have issues with accessing private class data if you don't move that around properly too as well as its accessors.
‎10-30-2017 08:37 AM
If in the project, right-click on your class and select "Save As". You will be given an option to duplicate the class. Now you have to go in and update all of your VIs from there. But that will get you around half way there.
‎10-31-2017 06:42 AM
@crossrulz wrote:
If in the project, right-click on your class and select "Save As". You will be given an option to duplicate the class. Now you have to go in and update all of your VIs from there. But that will get you around half way there.
That's how I do it. It's a bit laborious, but he, more motivation for making a design.