views:

39

answers:

1

Hi,

I'm developing complex UI application with several forms and widgets. The behaviour of the UI heavily depend on user rights, i.e. editors should see more widgets and forms than viewers, and admin should see all UI elements. Moreover, forms must be customized also. There is no actual problem with the layout, since layout could be customized via user dependent configurations. The main problem is form customization and behaviour customization, especially when the behaviour is rather complex.

If we start to use event-listener communication, this will possibly result in a chaos in the code (lots of IF / SWITCH constructions and so on).

So I would like to ask if there exist some information about best practices, patterns, books and useful examples.

Thank you!

A: 

For view/form customization, consider combining explicit View-Model separation to instantiate your UI (or modify the visibility of existing controls) with the Command Pattern, annotating your commands with the required user roles. You should investigate what support your platform provides, if any. For MS, consider e.g. the (somewhat dated) AzMan advice.

Behavioural customization: this depends on what kind of logic you are executing. The more role dependent variations you introduce, the greater the complexity. You might be able to use the Command pattern for this; but I haven't really found it necessary to go this far (usually, controlling the UI entries is good enough).

Generally speaking, try to make access checks declarative rather than coded as if or switch statements: elements of aspect oriented design might help. Whatever you do, you (or your testers) are going to have fun testing your application exhaustively (and exhaustingly)!

Pontus Gagge