These types of methods have always bothered me. Without digging through the code, I have no idea what the key or sub-value is supposed to be in this dictionary. I've done this myself about a thousand times, I'm sure. But it has always bothered me because it lacks so much information.
IDictionary<int,HashSet<int>> GetExportedCharges()
{
...
}
void GetVisitStatuses(IDictionary<int,HashSet<int>> exportedCharges)
{
...
}
Having the material in a dictionary makes sense, but all of the IDictionary methods have very abstract parameters. I suppose I could create a new class, implement IDictionary, and rename all of the parameters. It just seems like overkill. Makes be wish c# had a 'typdef' directive.
How do you avoid returning dictionaries like this? Or do you avoid this at all?
There is a very simple solution that you might find adequate:
public class IdToSetOfWidgetNumbersMap : Dictionary<int,HashSet<int>> { }
Advantages:
IdToSetOfWidgetNumbersMap
doesn't leave many questions openDictionary
if you preferDisadvantage:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With