title: Is it okay when a base class has only one derived class?
body: <p>I am creating a password module using OOD and design patterns. The module will keep log of recordable events and read/write to a file. I created the interface in the base class and implementation in derived class. Now I am wondering if this is sort of bad smell if a base class has only one derived class. Is this kind of class hierarchy unnecessary? Now to eliminate the class hierarchy I can of course just do everything in one class and not derive at all, here is my code. </p>
  
  <pre><code>class CLogFile
  {
  public:
      CLogFile(void);
      virtual ~CLogFile(void);
  
      virtual void Read(CString strLog) = 0;
      virtual void Write(CString strNewMsg) = 0;
  };
  </code></pre>
  
  <p>The derived class is:</p>
  
  <pre><code>class CLogFileImpl :
      public CLogFile
  {
  public:
      CLogFileImpl(CString strLogFileName, CString &amp; strLog);
      virtual ~CLogFileImpl(void);
  
      virtual void Read(CString strLog);
      virtual void Write(CString strNewMsg);
  
  protected:
      CString &amp; m_strLog; // the log file data
      CString m_strLogFileName; // file name
  };
  </code></pre>
  
  <p>Now in the code</p>
  
  <pre><code>CLogFile * m_LogFile = new CLogFileImpl( m_strLogPath, m_strLog );
  
  m_LogFile-&gt;Write("Log file created");
  </code></pre>
  
  <p>My question is that on one hand I am following OOD principal and creating interface first and implementation in a derived class. On the other hand is it an overkill and does it complicate things? My code is simple enough not to use any design patterns but it does get clues from it in terms of general data encapsulation through a derived class.</p>
  
  <p>Ultimately is the above class hierarchy good or should it be done in one class instead?</p>