Reputation: 4751
Following is the scenario.
I have something called as Domain
which can have multiple States
(Statekey-Statevalue pair) in it. The same StateKey can be present in multiple domains but with different StateValue.
e.g. StateKey named 'EconomicCapital' may be present in Domains like 'England', 'America' with values 'London', 'Washington' respectively.
Classes corresponding to these are in common library which can be consumed at client or service side as required.
I have a winform application in which I can select a specific domain. In any string, wherever I encounter any StateKey, I want to replace it by its StateValue for the selected domain.
I can think of following designs:
But there can be large number of instances where StateKey would be used, I do not think this approach is quite good snce it requires finding Domain object from the collection of domains and iterating through its State collection to find particular key.
OR
Could you please advice me which approach is more appropriate? Will there be any other approach/design?
(If the logic is implemented at service side; not just one winform application but many such applications can access it.)
Upvotes: 1
Views: 159
Reputation: 44275
Is this just a "thought project"/homework? Domain > State > StateValue relationships have to do something to become a class and use design patterns. This appears to be just a set of lookup operations. You may be better of using LINQ or a database.
Upvotes: 0
Reputation: 6814
What about something like
Dictionary<domain, Dictionary<statekey, statevalue>()
You could then find the key value pairs from the domain, and get the value from that.... Or am I missing something in your question?
Upvotes: 3