LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Daklu

LVOOP Interfaces

Status: Completed

Available in LabVIEW 2020 and later. 

(Similar title here.  Different concept.)

 

Many OO languages provide an Interface construct that allows objects in unrelated class hierarchies to expose similar functionality that can be called via common methods.  For example, a Car class and a Race class might both implement a Start method.  Unless their common ancestor has a Start method (which may not be practical) there's no way for me to take advantage of dynamic dispatching.  Interfaces allow an object to temporarily disguise itself as a different object so I can use a single vi on multiple objects.

 

Using the Car/Race example, I would like to be able to create an IStartable interface construct that defines a Start method.  Car and Race, in implementing IStartable, create their own Start methods that will override IStartable.Start.  I could then transform the Car and Race objects into an IStartable type and wire that into IStartable.Start.  IStartable.Start would then automatically transform each object back into its original type and call its member Start vi.

 

A couple points:

  • Classes need to be able to implement multiple interfaces.
  • There needs to be a way for class designers to indicate which interfaces it implements.  Setting that up in the class property dialog box seems like the best solution.
  • There also needs to be a way for class designers to designate which member vis to use when overriding an Interface method.  I can't think of a good way to do this in the vi itself, so I'd also manage these settings in the class properties dialog.
  • The illustration uses a Type Cast prim even though the actual type is not being changed.  It would need a new prim.
  • I've toyed with the idea of hiding interfaces on the bd by having an 'Invoke Interface Method' node that would automatically do the transformation and call back into the class' overriding method, but I think that restricts developers too much.
21 Comments
shb
Active Participant
Active Participant

It is similar for sure. But Go does check on compile time and not on run time as most (all?) duck type systems do.

(According to your linked wikipedia article Go uses structural typing. Not sure if this is right, it sounds more like a mix of both.)

 

(I am not a fan of duck typing. I vote for checking as much as possible as early as possible. In python test coverage should be high because even some typos can only be detected when running and testing a program.)

crcarlin
Member

As a quick note, I need interfaces so that I CAN implement a strict type structure.

 

Without interfaces I have to make a parent class extremely generic, with all methods any children might possibly call, even when they're not applicable to some children. Those show up at runtime when they could/should be handled at compile time.

 

Interfaces would hopefully let us better specify class types.

3esmit
Member

Why NI is taking so long to implement this? I am just updating LabVIEW if they improve LVOOP with interfaces suport!!!

 

C'mon, please implement this, make something just like java interfaces for labview interfaces!

I imagine that would be like a labview class but without the "<ClassName>.ctl" and it does not contains full VIs, but just the front panels (with VI connector).

In Class Properties, near Inheritance configuration would have the implementing interfaces, that could be choosen from this ones. 

fabions
Member

We need interfaces so we can make a true Application Separation Layer (would be mostly interfaces) that would be implemented by Device Specific Software Plugins ~ for the next generation test systems.

thols
Active Participant

The G# LabVIEW plugin has had interfaces for years. It works really well, but I do hope that it gets implemented in LabVIEW, so we can make a more elegant solution.

Certified LabVIEW Architect
Intaris
Proven Zealot

Check out the new abilities of Malleable VIs which offer class support based on method name.

 

It's not interfaces directly, but fills in a lot of gaps in that regard.

 

HERE, and HERE

wiebe@CARYA
Knight of NI

The CLA summit in Madrid had a presentation on a partial implementation for interfaces. NI (AQ) referred to the solution as (paraphrasing) "very elegant", only needing a little TLC.

 

The vibe I got was it will bring a build in solution within reach. Not sure about the current status, but there might be light at the end of the tunnel.

wiebe@CARYA
Knight of NI

This should be changed to "in development" or "in beta".

Darren
Proven Zealot
Status changed to: In Beta
 
TomOrr0W
Member

Hi Darren, could you check this similar idea of Daklu's to see if it also should be marked as "In Beta"?