LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview oop question: MUST A child class implement all parent methods?

My understanding and thoughts, as one who's used LVOOP occasionally.  Others may have different and better things to say:

 

1. Class data is always private.  It can only be directly accessed by member functions of that exact class, not by any other class in the inheritance hierarchy.  Direct access comes via Bundle/Unbundle By Name functions.

2. Accessor functions can be created that read or write the private data.  These functions can be public (often a bad idea), protected (usually best), or private (generally kinda pointless).  If protected, child classes can use them to have indirect access to parent data.

3. In my world at least, Accessor functions are never dynamic dispatch.  They access data that exists at a specific known level in the class hierarchy, thus you can use a static dispatch function from that specific level without "breaking" from OOP.

4. A child object is composed of a parent part that's kinda hidden and implied and a child part that's visible and explicit.  It contains both its own unique private data PLUS the private data owned by the parent part of itself. 

5. When a child is defined, its private data should NOT include items that would already be defined/owned by its parent part.  Here, if the task refnum is defined as parent-level data, there should NOT be an additional task refnum defined in the child data.

 

I've found that a lot of the implications pretty much work themselves out once you get a solid understanding of the stuff above.

 

 

-Kevin P

Message 11 of 13
(603 Views)

All points are spot on.

 

This one seems especially important in this thread:


Kevin_Price wrote: 

5. When a child is defined, its private data should NOT include items that would already be defined/owned by its parent part.  Here, if the task refnum is defined as parent-level data, there should NOT be an additional task refnum defined in the child data.

 

One of the first thing I do after "Save As" on the parent class to make a child, is delete the private data in either the child or the parent. This will break the methods that need to be either removed (from parent or child) or adjusted.

 

Not deleting copies of the parent's private data in the child's private data or visa versa will certainly cause confusion and probably bugs.

 

Message 12 of 13
(584 Views)

Good stuff all of you! Kevin's #5 and @weibe's response on deleting child private data after a Save As copy, are spot on replies to my specific issue. Crossrulz replies were very helpful too. I will make some changes per recommendations and get back with some more questions. I've been pulled away for a bit. Hope you'll all stay tuned.

0 Kudos
Message 13 of 13
(557 Views)