title: Complicated initialization in constructor
body: <p>I have a sort of model that manages maps of varying data.  I've read that constructors should not contain business logic, but I've also read that constructors are free to do what they need to do to initialize the state of the object.  What if, given map A and map B in the constructor, I want to merge those two maps and set the result in a third field.  Maybe I also want to do some cleanup or something.  Is this bad practice?  If so, why?</p>
  
  <pre><code>public class MapManager {
  
      private Map&lt;String, Object&gt; mapA;
      private Map&lt;String, Object&gt; mapB;
      private Map&lt;String, Object&gt; combinedMap;
  
      public MapManager(Map&lt;String, Object&gt; mapA, Map&lt;String, Object&gt; mapB) {
          this.mapA = mapA;
          this.mapB = mapB;
          this.combinedMaps = initCombinedMap(mapA, mapB);
      }
  
      public Map&lt;String, Object&gt; getMapA() {
          return mapA;
      }
  
      public Map&lt;String, Object&gt; getMapB() {
          return mapB;
      }
  
      public Map&lt;String, Object&gt; getCombinedMap() {
          return combinedMap;
      }
  
      private static Map&lt;String, Object&gt; initCombinedMap(Map&lt;String, Object&gt; mapA, Map&lt;String, Object&gt; mapB) {
          Map&lt;String, Object&gt; combinedMap = new HashMap&lt;&gt;(mapA);
  
          if (mapB != null) {
              mapB.forEach(combinedMap::putIfAbsent);
          }
  
          return combinedMap;
      }
  }
  </code></pre>