You may remember Karl from a few months back. Karl's organization is notorious for crunch, and it results in some awful sins when you're trying to cram 50 hours of work into the last five hours before launch.
Karl didn't write this particular bit, but dreads the day when he has to look at it or change what it does.
private void InitializeDictionaries()
{
filePaths = new HashSet<string>();
preDecryptionFiles = new Dictionary<string, string>();
trailerInfo = new Dictionary<string, string[]>();
fileHeaders = new Dictionary<bool, Dictionary<string, string>>()
{
{ true, new Dictionary<string, string>() },
{ false, new Dictionary<string, string>() }
};
separatedFiles = new Dictionary<bool, Dictionary<bool, Dictionary<string, List<string>>>>
{
{
true, new Dictionary<bool, Dictionary<string, List<string>>>
{
{ true, new Dictionary<string, List<string>>() },
{ false, new Dictionary<string, List<string>>() }
}
},
{
false, new Dictionary<bool, Dictionary<string, List<string>>>
{
{ true, new Dictionary<string, List<string>>() },
{ false, new Dictionary<string, List<string>>() }
}
}
};
}
The job of this code is to prep some data structures which will be used to store the contents of some files. Writing a class to handle that would be the obvious solution, but this developer instead went with the "let's nest a bunch of dictionaries inside of each other," approach. The separatedFiles
nest their dictionaries three deep, and contain a list of strings, so that's four tiers of nested generics. I do not know why there are the boolean keys. I don't think I want to know.
None of this is a "code smell". This is a "code stench", and it's not gonna wash out.