title: Package-by-layer VS package-by-feature library naming?
body: <p>I know this has several associated posts, but I have some specific questions which I am hoping I can get help with. Sorry if they are very basic..</p>
  
  <p>Here is a sample problem - very simplified, but you get the picture - I have several objects, which have some common function e.g. departments in a pharmaceutical company - neurology, oncology, infection etc. They all need to parse patient document files, and upload data to the database. Of course the nature of the data is slightly different for each department. If I used package-by-feature, I would have</p>
  
  <pre><code>com.company.neurology
        Neurology.java
        NeurologyDocument.java
        NeurologyDAO.java
  
  com.company.infection
        Infection.java
        InfectionDocument.java
        InfectionDAO.java
  </code></pre>
  
  <p>etc.
  The problem is that I need an abstract class that the Document classes need to extend e.g.</p>
  
  <pre><code>AbstractDocument.java
  public class AbstractDocument
  {
        public void validateDocument(){...}
        public void readDocumentHeader(){...}
        public void readDocumentFooter(){...}
         ...
  }
  </code></pre>
  
  <p>Some data access files e.g.</p>
  
  <pre><code>DBConnection.java
      public class DBConnection
      {
          public void makeConnectionToDB() {... }
          public void createCache() {... }
          public void closeConnectionToDB() {... }
      }
  </code></pre>
  
  <p>some error classes</p>
  
  <pre><code>ParseError.java, PatientNotFoundException etc.
  </code></pre>
  
  <p>If packages are by feature, where do these common classes/interfaces go?</p>