Assume you are building some kind of an information system. Say it’s an issue tracker (yeah I know, I have a blank spot in the creative-part of my brain).
Now say you want some visual customisation based on the current context - like a different look’n’feel for each customer on a multi-tenant application, or a slightly different menu for an Admin.
Kinda easy - right? you’d stick some overriding CSS rules for the former (say on CUSTOMER_ID.css), and some kind of a simple view logic for the latter (say <% if (isAdmin) { %> … <%}%>, or some type of CodeBehind crap if you’re a WebForms lover).
But - what if you want to customise the behaviour according to context? say that for some actions, for a given customer, an email should be sent, or a webservice be called, or some default data should be set for a given form.
The first option would be to create an interface ICustomerActions, and a DefaultCustomerActions which will be in charge of the, well, default behaviour. then for each customer you’d derive from DefaultCustomerActions (or directly from the interface if it’s completely different).
Then you’d use some kind of a Factory (or your container) to resolve the needed ICustomerActions instance according to the context (say a customerId in the Session).
There are two problems in this approach
So how do you think I solved this problem? How would you do that?