title: How should I access another module's DAL?
body: <p>OK, so I have a couple of modules in my application. One is called ProductCatalogue and another is called Contracts. We now have a need for a contract to be associated with a number of products (eg the products which a party to a contract is allowed to order). Within the ProductCatalogue module we have a ProductDAL class which has the following functions</p>
  
  <pre><code>Public Function GetProducts()
      Set GetProducts = GenerateProductsList("SOME SQL")
  End Function
  
  Private Function GenerateProductsList(selectQuery)
      Dim list : Set list = New List
      Dim results : results = GetResultsFromDB(selectQuery)
      '... for each row
          Dim product : Set product = New Product
          product.Id = results(field, index)
          list.Add(product)
      'loop ...
      Set GenerateProductsList = list
  End Function
  </code></pre>
  
  <p>Now, I want to get all products associated with a contract so I want to write a function that looks like this</p>
  
  <pre><code>Public Function GetProductsForContract(contractId)
      Set GetProductsForContract = GenerateProductsList("SOME SQL")
  End Function
  </code></pre>
  
  <p>My question is, where should I put this function? I want to use the existing GenerateProductsList() function as it is a lot more complicated than it looks. There my question is "Where should I put GetProductsForContract"?</p>
  
  <p>My options:</p>
  
  <p>1) Put it in ProductDAL.
  <br />
  The problem with this is that ProductDAL suddenly becomes aware of what a contract is and I can see this getting quickly full of functions such as GetProductsForAllContracts, GetProductsForLiveContracts, etc, etc (and more when other modules want to access products) so really I'd like to keep those functions with the rest of the Contracts code.</p>
  
  <p>2) Put it in ContractDAL and make ProductDAL.GenerateProductsList public.
  <br />
  Should I really be exposing this?</p>
  
  <p>3) Create a new class which one method which has the sole responsibility of taking in an SQL dataset and returning a list of products.
  <br />
  Actually isn't this the same as 2?</p>
  
  <p>4) Stop doing it wrong.
  <br />
  I'm not sure how. Show me. Then hold me.</p>
  
  <p>edit: Also, what about AddProductToContract, RemoveProductFromContract where does this go? I'm leaning towards a new ContractProductManager class but what's the best way to access GenerateProductsList()</p>