DQMH Consortium Toolkits Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Are singleton modules justified?

Hi,

 

After I have created several singleton and cloneable modules in our project I'm wondering if one should ever create a singleton? It happened to me that I created a singleton module and later on it turned out that we need to launch more than one instance of it. If the opposite happens (you create a cloneable but dont need clones) then you can simply launch just one instance.

 

Having cloneables only would generalize the DQMH modules at some degree, which is also a benefit.

 

I'm not making a hidden statement that everything should be cloneable, I'm really wondering about your opinion.

 

Thx.

0 Kudos
Message 1 of 4
(860 Views)

There certainly are teams that decide to work with cloneables exclusively.

 

For me personally (not even HSE-wide), there are two reasons not to make everything a cloneable module:

 

  1. Most of the times, I do not need a cloneable. A singleton will do just fine. 
  2. Cloneables come with an overhead for managing clones - both internally (clone registration, events being reused, ...) and externally (need to store the clone ID*).

My decision is to go with singletons as much as possible. 




DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (The Future of Team-Based LabVIEW Development)


Message 2 of 4
(839 Views)

@joerg.hampel wrote:

There certainly are teams that decide to work with cloneables exclusively.

 

Historically, this was maybe because on RT prior to DQMH 5, you could only use cloneables! I used to be one of those that believed everything should be a cloneable.  I have since changed my thoughts on this to the following:

 

1) Hardware/instrument/device modules are best suited to cloneable.  Because quite often you might have multiple devices of the same type in your system.  For instance: multiple pumps, or multiple barcode scanners, or multiple cameras.  So our default for hardware/instrument/device modules are cloneable.

2) We make user interface modules singteton by default. It's pretty rare in our applications that a user interface module needs to be cloneable.

3) When developing in RT, we aim to make singleton modules default (unless there's a very good reason to make it cloneable - ie. multiple instances of a hardware device).  Cloneable modules are harder to debug in RT.

Christopher Farmer

Certified LabVIEW Architect and LabVIEW Champion
DQMH Trusted Advisor
https://wiredinsoftware.com.au

Message 3 of 4
(812 Views)

I'm on the "cloneable only when needed" team 🙂

 

1/ as @joerg.hampel said, there is an overhead in managing clones

2/ I do like my code to explain itself the better it can. If I see a cloneable module in the code, I expect to see more than one instance possibly loaded.

 

Sometimes it happens you need to move from singleton to cloneable. It's not the most interesting work, but it only happened twice in 4 years for me (and I basically use DQMH every working day).


Olivier Jourdan

Wovalab founder | DQMH Consortium board member | LinkedIn |

Stop writing your LabVIEW code documentation, use Antidoc!
Message 4 of 4
(762 Views)