LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Singleton vs. action engine

Hello all,

 

I'm trying to find a good break down of the differences (advantages/disadvantages) between using a singleton object and an action engine.

 

Also, is it possible to have multiple instances of a singleton (I know, sounds silly) with a different Checkout/Checkin for each.  If this is not possible then to me it seems like a singleton is basically the same as an AE just created using a OOP point of view.

 

Thanks.

0 Kudos
Message 1 of 4
(2,717 Views)

In a very basic sense they're similar, but when adding inheritance, the possibility to add functionality with different connector panes and similar the differences starts to be noticable. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 4
(2,702 Views)

Hi GollumGTH,

 

Yamaeda is correct that they are very similar.  One thing to be careful of when using functional globals is to make sure they remain nonreentrant (the default).  If they become reentrant, then multiple instances could be created in memory defeating their purpose.

 

Check out this link for a thorough explanation of the singelton architecture: http://decibel.ni.com/content/docs/DOC-13462 (Singelton Pattern)

 

If you would like to have a class similar to the singleton but with mutliple instances the recommendation is that you use the Extensible Session Framework.

 

Have a great day,

 

Chris

 

 

Applications Engineer
National Instruments
0 Kudos
Message 3 of 4
(2,664 Views)

Another thing the LVOOP provides is some levels of protection for your data. You define the API supported via your public methods and can limit access to the data. In addition, you have much more flexibility in how each method is defined with respect to it's inputs and outputs. You are limited to a single connector pane like Yamaeda stated. Inheritance and dynamic dispatch are very powerful tools. Unlike AEs you can create multiple instances of your singletons which again provides more flexibility.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 4
(2,657 Views)