title: Is a deep nested Dictionary an antipattern?
body: <p>I have a structure that can be very easily represented using a three-deep nested dictionary, like so</p>
  
  <pre><code>private static Dictionary&lt;string, Dictionary&lt;string, Dictionary&lt;string,string&gt;&gt;&gt; PrerenderedTemplates;
  </code></pre>
  
  <p>Where the structure might be used something like this</p>
  
  <pre><code>PrerenderedTemplates[instanceID][templategroup][templatepart]
  </code></pre>
  
  <p>Now, I realise that this code is hard to read, because from looking at the definition statement, you can't tell what it's being used for. The only advantage I can really see in changing it to <code>Dictionary&lt;string, PrerenderedTemplate&gt;</code> is readability. Converting each nesting into its own class (e.g <code>class PrerenderedTemplate{} class TemplateGroup{} class TemplatePart{}</code>) would add many more lines of code for little (if any) computational advantage. As far as I can see.</p>
  
  <ul>
  <li>So, is my approach "ok" or should I go the extra mile and create seperate classes? </li>
  <li>Is it okay to cover how the nested <code>Dictionary</code> works in the documentation/comments</li>
  <li>Is there a best practice for handling this sort of nesting?</li>
  <li>Bear in mind, this is a private member, it doesn't need to be straightforward for people using the class.</li>
  </ul>
  
  <p><strong>Update</strong></p>
  
  <p>So, inspired by Reza, but unable to use Tuples, I decided to create my own key generator and implement his pattern like this:</p>
  
  <pre><code>private Dictionary&lt;string, string&gt; PrerenderedTemplates;
  private string GetPrerenderedTemplateKey(string InstanceId, string FeatureId, string OptionId)
  {
      return new StringBuilder(instanceId)
      .Append(FormatTools.LIST_ENTRY_DELIMITER)
      .Append(templategroup)
      .Append(FormatTools.LIST_ENTRY_DELIMITER)
      .Append(templatepart).ToString();
  }
  </code></pre>
  
  <p>Where <code>FormatTools.LIST_ENTRY_DELIMITER</code> is the Unicode Private Use Character <code>0xe04d</code>.</p>