LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Command Pattern" decouples a command from its data - but exactly how?

Solved!
Go to solution

Hi Paul,

 

Yes, sorry I just quickly looked at the attached screenshot. 

 

The magic of using dynamic dispatch is that you could build those objects into an array, then feed them into the parent method (wrapped in a for loop) and it will automatically call the correct child method at runtime. This is more powerful than the typical (non-OOP) polymorphic VI which must be set at edit-time.

 

I think you can do that with your objects, you should try it for fun 🙂

0 Kudos
Message 11 of 15
(1,201 Views)

Much thanks Gregory, I was 1cm from the finish line, and I just needed that slight tailwind to get across.  I think my next step is to learn how to use the new Interfaces, then I'll be ready to redo my controller command code - paul

Message 12 of 15
(1,196 Views)
Solution
Accepted by PaulOfElora

Even more, you can add children to the parent, without having to change the users of the class. The only thing that comes close is passing a (strict) VI reference, but you won't get inheritance, nor clarity.

 

You can even make a composite child, containing an array. Now you have one wire, telling which command to execute, where a command can even be an array of commands. Even more, the command can be an array of commands where each element can be an array. Now you have full blown recursion, which can be very powerful when working with anything hierarchical (Formulas "(a+b)*(b-(c*2)), files like XML, JSON, user interfaces, etc.).

 

Check Configuration-File-Library (the query part) for an example... These could be a bit intimidating, some powerful stuff going on there.

0 Kudos
Message 13 of 15
(1,174 Views)

Thanks Carya - sounds like a Bazillion possibilities, got to digest what you're saying, also vis-a-vis the video of Aristos explaining/introducing 2020 Interfaces.  If I can get even a little bit of this implemented before my bosses shoot me for being late I'll have really grown in my understanding.  I'm the only one at work using LabVIEW and people like you are my only mentors - very grateful! paul

Message 14 of 15
(1,167 Views)

Whoa Dude! There's a lot to learn in this barge of Config stuff!  Super-grateful!

0 Kudos
Message 15 of 15
(1,154 Views)