title: Best Practices for Using Multi Level HashMap in Java
body: <p>We have a situation where we are ending up using multi-level hash maps; that is, a hash map inside of a hash map, three or four levels deep.</p>
  
  <p>Instinctively this felt wrong somewhere. I have read posts here that talks about how to iterate/use a multi-level hash map, but hardly any of them say what is the best practice for this.</p>
  
  <p>Why are multi level hash maps bad, and what would be the better design, if any?</p>
  
  <p>Here is the sample design of multi-level hash maps that we have:</p>
  
  <pre><code>Map&lt;String, Object1&gt; map1;
  
  class Object1 {
      String version;
      Map&lt;String,Object2&gt; map2;
  }
  
  class Object2 {
      Map&lt;String,List&lt;Object3&gt;&gt; map4;
      Map&lt;String,String&gt; map5;
  }
  </code></pre>