From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DQMH Consortium Toolkits Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How to decide if an event should be a Request or a Broadcast?

Hi,

 

I have gotten different flavors of this question lately, so I thought I would share the answer here in case it would help someone else.

 

Traditionally, a "Request" is when the outside code is asking the DQMH module to handle the event. A "Broadcast" is when the outside code is registered to listen and handle events that the DQMH module might generate. 

 

For example, if I have a DQMH Module called "File Logger", it might have a request called 
 "Log data to File" with an argument that contains the data. It also might have a broadcast called "New Log Data File Created" with an argument that contains the new log data file name.

 

The exception would be if you are avoiding a circular dependency. For example, we have a top-level application that launches a database module but the top level application has the user credentials and level of security, if we had the database module request from the top-level application, we would create a circular dependency. Therefore, we have the database module broadcast: "help, if anybody is listening, I need to have the security credentials". The top-level module is registered for that broadcast and when it gets it then it sends the request to the database module: "here you go, these are the security credentials". This also opens the possibility to have in the future another module manage users and it would still be transparent to the database module.

 

I hope this helps clarify the question of whether your events should be Requests or Broadcasts. 

 

Happy wiring,

Fab

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 1 of 1
(3,060 Views)