Design Check for cross module interaction

Topics: CAB & Smart Client Software Factory
Jun 8, 2006 at 1:15 PM
originally posted by: sklett

I wanted to run a scenario by you all that I want to implement. Every approach I have come up with is flawed so I figure, once again, I'm going about things wrong.

2 modules; EmployeeModule and LabelsModule - Employee module manages various aspects of employees and LabelsModule generates, edits and prints various labels.

While EmployeeModule is active and a user is working with a view, I need to have a button that when pressed will generate and print a label with that employees information.

LabelsModule has several views such as: PrintPreviewView, EditLabelView, GenerateLabelStatusView, etc.

When the button is pushed in EmployeeModule's View to generate the label, I want to show the various appropriate views from LabelsModule.

Here are the approaches I have thought of or tried already and the reasons they have failed (for me)

1) Refactor LabelsModule code to generate employee label into child WorkItem so that it can be executed from a different module. I liked the idea of creating or "getting" a reference to the EmployeeLabelWorkItem and calling Run(Employee emp) from my EmployeeModule.
- Couples EmployeeModule to LabelsModule, requires reference.
- EmployeeLabelWorkItem.Run(Employee e) returns as soon as it's done adding it's views and calling Show(). This then requires EmployeeModule to somehow check of be notified when EmployeeLabelWorkItem has completed it's tasks.

2) Create a "Common" service, IE: LabelsService that could be shared by different modules. This service would be called from EmployeeModule and would then generate the labels and print them out.
- Does satisfy my need to see the LabelsModules views.

There were some other short ideas that didn't make it too far.

I thought that I could also use the EventBroker to publish an event, IE: "PrintEmployeeLabel" and the LabelsModule would subscribe and jump into action. I backed off of this after looking at the BankTeller imp. as I noticed very light use of the EventBroker and wanted to try and follow the reference implementation.

If anyone out there understands the issue and has a suggestion how to design a solution or even just some tips, I would really appreciate it.

Thanks for reading everyone,
Jun 8, 2006 at 1:25 PM
originally posted by: matiaswoloski

Hi Steve,
Take a look at latest RI2 drop. We implemented a scenario where the BranchSystems module create a CustomerWorkItemController and at the time is created an event CustomerWorkItemCreated is raised. The EventArgs of the event is the CustomerWorkItemController itself.
BasicAccounts ModuleController handles that event (as any other module that might want working with the customer does). In the handler it will add views on the workitem and show them in a workspace the CustomerWorkItemController or its ancestors know. You won't need a reference between modules.

Jun 8, 2006 at 2:29 PM
originally posted by: MarcoPaul

I would have to say the EventBroker approach sounds the cleanest. If you find yourself having to listen to numerous events, I would refactor to the service approach.
Jun 9, 2006 at 7:28 AM
originally posted by: sklett

Hi Matias,

That is a good example, I hadn't downloaded the latest drop, but I'm glad you pointed me to it.

I've got the basics up and running, so it was a great help, thank you again.

Jun 9, 2006 at 7:30 AM
originally posted by: sklett

Hi Marco,

I've got it working now with two basic EventTopics, one to start the workitem and another to respond when it's finished. It's working well, don't think I will need to go the Service route......yet :0)