Question

Following Ordering menu items fed from multiple modules the question was raised to me, who is responsible for ordering and alignment of menu items in a modular application.

The previous link suggests that the module who offers the menu item is responsible for saying where it will be located ("at index n", "after module x", "before module y"). Multiple further resources propose a IMenuService where modules can register or remove their menu items, e.g. PRISM Framework.

But intuitively I would say that the main application should take the responsibility. Modules should not necessarily know other modules just to order their own menu item. Nor should the module in principle decide itself where it appears in the menu in a larger context. E.g. the logout menu item should have some offset to other items or a certain menu item gets a special color because it is consired important by the application at the moment.

So resulting from that consideration I thought how the main application (core) could handle this. But in this case the main application must have knowledge of the menu items and their concrete types. Thus, must newing up the items offered by the different modules or using the resolve method of the IOC container to differ between them resulting in a kind of service locator anti-pattern. (Constructor injection with n menu item dependencies seems not right to me either)

So I don't know if this is an opinion based question, but for sure a design question.

What would you propose as a solution or how is this scenario handled by other applications? What is the standard way of composing the menu?

Further information: I am currently developing a modular mobile application with Xamarin and Prism (with DryIOC) as the MVVM and IOC framework.

Was it helpful?

Solution

Have you considered that the menu itself is a standalone module? I have to admit I don’t know what you mean by “core” of the application in this context, so I don’t know if it needs to know about all the modules, but I can see how a menu could be a standalone module whose responsibility is to know how to order the display of the other modules and can send events into the core like “user selected module X” and so on.

Licensed under: CC-BY-SA with attribution
scroll top