Jump to content


Photo
- - - - -

Packed Project Library Exported Class Methods?


  • Please log in to reply
7 replies to this topic

#1 lvb

lvb

    Very Active

  • Premium Member
  • 159 posts
  • Location:Michigan
  • Version:LabVIEW 2012
  • Since:2003

Posted 17 April 2012 - 08:19 PM

Is there a way to control which VIs of a LVOOP class are exported (visible) in a packed project library? I would like to expose only a few methods of a class.

Note: Some of these are dynamic dispatch which cannot be set to Community or Private in the class.

Brian

Certified LabVIEW Architect (CLA)

Certified TestStand Developer (CTD)


#2 Aristos Queue

Aristos Queue

    LV R&D: I write C++/# so you don't have to.

  • Premium Member
  • 2,620 posts
  • Location:Austin, TX
  • Version:LabVIEW 2011
  • Since:2000

Posted 18 April 2012 - 09:16 AM

To control what is visible, set the access scope. The dynamic dispatch VIs can be set to protected, which is the only other meaningful scope for dyn disp -- it doesn't make sense to have a dynamic dispatch method that cannot be overridden by children.

There is a valid use case for creating a wrapper class that has a reduced set of methods that wraps an inner class. This is done a lot in various programming languages to create a read-only version of the class, so the wrapper class only has methods for reading values, not writing them. You would then hide the core class inside the packed project library (making it private to the library) and expose your wrapper class only.

#3 lvb

lvb

    Very Active

  • Premium Member
  • 159 posts
  • Location:Michigan
  • Version:LabVIEW 2012
  • Since:2003

Posted 18 April 2012 - 02:25 PM

To control what is visible, set the access scope. The dynamic dispatch VIs can be set to protected, which is the only other meaningful scope for dyn disp -- it doesn't make sense to have a dynamic dispatch method that cannot be overridden by children.

Hence the reason for my post. Dynamic dispatch VIs seem like a catch 22 with lvlib scope. You are forced to wrap the class to hide just a single VI.

There is a valid use case for creating a wrapper class that has a reduced set of methods that wraps an inner class. This is done a lot in various programming languages to create a read-only version of the class, so the wrapper class only has methods for reading values, not writing them. You would then hide the core class inside the packed project library (making it private to the library) and expose your wrapper class only.

For large projects, this seems like a lot of work to hide one or two dynamic dispatch VIs. It would be nice to control what VIs are visible/exported in the lvlib properties.

Any thoughts? I may put this into the idea exchange...

Brian

Certified LabVIEW Architect (CLA)

Certified TestStand Developer (CTD)


#4 Aristos Queue

Aristos Queue

    LV R&D: I write C++/# so you don't have to.

  • Premium Member
  • 2,620 posts
  • Location:Austin, TX
  • Version:LabVIEW 2011
  • Since:2000

Posted 19 April 2012 - 01:32 PM

Hence the reason for my post. Dynamic dispatch VIs seem like a catch 22 with lvlib scope. You are forced to wrap the class to hide just a single VI.

Why isn't protected scope sufficient hiding?

For large projects, this seems like a lot of work to hide one or two dynamic dispatch VIs. It would be nice to control what VIs are visible/exported in the lvlib properties. Any thoughts? I may put this into the idea exchange...

That would be unusual among the world's OO languages. I'm not saying it's a bad idea, but when none of the major OO languages that I know of do it, I always have to ask why. Scope is not one of those areas that is impacted by dataflow.

#5 lvb

lvb

    Very Active

  • Premium Member
  • 159 posts
  • Location:Michigan
  • Version:LabVIEW 2012
  • Since:2003

Posted 19 April 2012 - 02:15 PM

Why isn't protected scope sufficient hiding?

Because the VIs are still visible in the Packed Project Library (they are not hidden):lvlibp_interface_with_protected.png
Since they shouldn't be used, the user will question why they are visible.

That would be unusual among the world's OO languages. I'm not saying it's a bad idea, but when none of the major OO languages that I know of do it, I always have to ask why. Scope is not one of those areas that is impacted by dataflow.

Isn't this a feature of the Packed Project library (that does not exist in other languages)? The PPL is used for "interface" and it would be nice to separate the "presentation" from the class itself. This would reduce a whole lot of "busy work" wrapping classes.

Thanks,
Brian

Brian

Certified LabVIEW Architect (CLA)

Certified TestStand Developer (CTD)


#6 mje

mje

    The 500 club

  • Premium Member
  • 814 posts
  • Location:Milford MA USA
  • Version:LabVIEW 2011
  • Since:1997

Posted 19 April 2012 - 04:34 PM

There is a valid use case for creating a wrapper class that has a reduced set of methods that wraps an inner class. This is done a lot in various programming languages to create a read-only version of the class, so the wrapper class only has methods for reading values, not writing them. You would then hide the core class inside the packed project library (making it private to the library) and expose your wrapper class only.

To me a better approach would be to just support private inheritance.

/ducks

#7 Aristos Queue

Aristos Queue

    LV R&D: I write C++/# so you don't have to.

  • Premium Member
  • 2,620 posts
  • Location:Austin, TX
  • Version:LabVIEW 2011
  • Since:2000

Posted 20 April 2012 - 05:20 AM

Isn't this a feature of the Packed Project library (that does not exist in other languages)? The PPL is used for "interface" and it would be nice to separate the "presentation" from the class itself. This would reduce a whole lot of "busy work" wrapping classes.

PPLs are not a part of the LabVIEW language. They're just packaging for functionality, no different in many ways to a .zip file. The PPL is not a presentation layer or any other formal aspect. It's just a tool for getting VIs to load faster.

When you ask for changes to scope, that addresses language features, which means changes to the run time behaviors that would impact dev environment and run time environment alike, regardless of packaging.

To me a better approach would be to just support private inheritance.

A good write up of why composition is preferred to private inheritance:
http://www.parashift...nheritance.html

#8 lvb

lvb

    Very Active

  • Premium Member
  • 159 posts
  • Location:Michigan
  • Version:LabVIEW 2012
  • Since:2003

Posted 23 April 2012 - 03:54 PM

PPLs are not a part of the LabVIEW language. They're just packaging for functionality, no different in many ways to a .zip file. The PPL is not a presentation layer or any other formal aspect. It's just a tool for getting VIs to load faster. When you ask for changes to scope, that addresses language features, which means changes to the run time behaviors that would impact dev environment and run time environment alike, regardless of packaging.

It sounds like this would be a major addition (or would never happen), but it would be nice if the lvlib supported a presentation layer

Brian

Certified LabVIEW Architect (CLA)

Certified TestStand Developer (CTD)