❔ 2D Dictionary
i'm wondering if it would be possible to create a 2d Dictionary of sorts where it would look something like: Dictionary<key, Dictionary<key, value>>. Context is each server should have a dictionary of clients, with an associated tcpClient value.
3 Replies
The rule of thumb that I've always followed is that you should start to wrap your anonymous data into classes at this point, as it's the same thing but with more compiler hints
Perhaps you should instead model your data as a Dictionary of
Client
classes, with a tcpClient
property
It's pretty much the same logic as with dictionaries except you get the benefit of giving names to your properties, being able to store multiple properties and having better exceptions
If you've got a whole collection of TCPClient
s per Client
I'd still recommend storing that collection as a property - again to make the code more self-documentingIt might be much easier and clearer to just key your dictionary with a tuple.
So not
Dict<TKey1, Dict<TKey2, TValue>>
but Dict<(TKey1, TKey2), TValue>
But honestly that's more for quick stuff, Rotor is 100% right that you could and should make a "neater" model around this. Proper naming, type hierarchy that makes sense etcWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.