title: Large complicated constructor or private method?
body: <p>I am implementing a class to represent legacy files.  The files are binary and need extensive parsing.  There will be probably thousands of lines of code to parse the file.  I have two constructors in the class:</p>
  
  <pre><code>class CrmxFile {
  
  public:
      CrmxFile(std::wstring filename);
      CrmxFile(std::ifstream&amp; file);
  
  ...
  }
  </code></pre>
  
  <p>As the object doesn't make sense without the content of the file, all the parsing needs to be done while constructing the object.  I was going to implement a massive constructor (the one with the stream parameter), but a colleague of mine argues that it's not a good practice to have very large constructors.  Instead, I should create a private method that would do the parsing and call this method from the constructor after checking the stream is readable and, maybe, reading the file header to validate the stream contains correct data.</p>
  
  <p>Are there any guidelines/rules/conventions/etc. that govern such situations?  Essentially (in pseudo-code), which of the two approaches is better,</p>
  
  <p>long constructor:</p>
  
  <pre><code>CrmxFile::CrmxFile(std::ifstream&amp; file) {
      if (file is not readable) {
          throw new CmrxException(read_error);
      }
  
      CmrxHeader header(file);
      if(!header.isValid()) {
          throw new CmrxException(invalid_file);
      }
  
      //now do all the reading/parsing of the file
      //constructor may end up being a thousand lines of code
      ...
  }
  </code></pre>
  
  <p>or short constructor and helper method:</p>
  
  <pre><code>class CrmxFile {
  
  public:
      CrmxFile(std::wstring filename);
      CrmxFile(std::ifstream&amp; file);
  
  private:
      ParseFile(std::ifstream&amp; file);
  
  ...
  }
  
  CrmxFile::CrmxFile(std::ifstream&amp; file) {
      if (file is not readable) {
          throw new CrmxException(read_error);
      }
  
      CrmxHeader header(file);
      if(!header.isValid()) {
          throw new CrmxException(invalid_file);
      }
  
      ParseFile(file);
  }
  
  void CrmxFile::ParseFile(std::ifstream&amp; file) {
      //do all the reading/parsing of the file here
      ...
  }
  </code></pre>