From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LVOOP composition and delegates

LVOOP doesn't support multiple inheritance, deciding instead to favour composition and aggregation (which happens to coincide with the "Gang of four" IIRC).

 

When we are working with composition (An object contains sub-objects for some or all of its functionality) when do we start to talk about delegates?  At what stage does a sub-object of any of my given classes become a delegate?  Are there any guidelines as to what is a delegate and what not?

 

If I have a Class A which exposes Methods 1,2,3,4 and 5 to the outside world I may choose to use Class B (or a derivative class) to implement Methods 3,4,and 5.  When does this class become a delegate?

 

Shane.

0 Kudos
Message 1 of 5
(2,560 Views)

Delegation is not really a strictly defined term. In fact, every object that is used to do some other object work becomes delegate (as in your Class A and Class B example)... And does it really matter? 😉

0 Kudos
Message 2 of 5
(2,520 Views)

Could you explain more what about LVOOP not supporting multiple inheritance and why that is keeping you from accomplishing something?

 

The way you describe delegation sounds right to me.  I do Composition and Delegation all the time in my LVOOP designs.  It is good to be on the same page when discussing what we call these patterns.  That being said, I read design pattern books to get my OOP juices flowing.  Not necessarily to look for exact solutions because they tend to be too generatlized to be directly applicable to a lot of real world problems.

0 Kudos
Message 3 of 5
(2,514 Views)

Well it's important if you want to describe an architecture you're proposing to not get the term all wrong.  that normally goes doen badly.....

 

Your answer coincides with my own feelings, so I guess I'll go with that.

 

Thanks

 

Shane.

0 Kudos
Message 4 of 5
(2,483 Views)

@Nickerbocker wrote:

Could you explain more what about LVOOP not supporting multiple inheritance and why that is keeping you from accomplishing something?

 

The way you describe delegation sounds right to me.  I do Composition and Delegation all the time in my LVOOP designs.  It is good to be on the same page when discussing what we call these patterns.  That being said, I read design pattern books to get my OOP juices flowing.  Not necessarily to look for exact solutions because they tend to be too generatlized to be directly applicable to a lot of real world problems.



The lack of multiple inheritance is not keeping me from accomplishing anything at all.  I fully agree with AQ that anything which can be done with multiple inheritance can also be done with compositing.  I was just a little unclear as to when an object becones a delegate.

 

Shane.

0 Kudos
Message 5 of 5
(2,481 Views)