title: Layered Architechture & Encapsulation
body: <p>I'm developing a project, ultimately it is going to be a web app. But I'm trying to follow a sort of layered approach for the business objects and data access, i've created the following class library projects in a single blank solution:</p>
  
  <pre><code>MyCompany.MyProject.Repository
  MyCompany.MyProject.Model
  MyCompany.MyProject.Service
  </code></pre>
  
  <p>MyCompany.MyProject.Repository has a reference to MyCompany.MyProject.Model
  MyCompany.MyProject.Service has a reference to MyCompany.MyProject.Model and MyCompany.MyProject.Repository.</p>
  
  <p>This little framework of mine is going to be used by multiple applications in the future and so I am creating them seperately to the web app.</p>
  
  <p>I have two questions:</p>
  
  <ol>
  <li><p>With regards to layering the app is this approach correct, the web app (Or any app that needs to use my framework) will need to have all three DLL's in it's Bin directory - am I understanding this correctly?</p></li>
  <li><p>The MyCompany.MyProject.Model project holds all of my business objects. With regards to encapsulation - for example I have a Customer object:</p>
  
  <p>Public Class Customer</p>
  
  <p>Private _customerID As Int32</p>
  
  <p>Public Property CustomerID() As Int32
      Get
          Return _customerID
      End Get
      Friend Set(ByVal value As Int32)
          _customerID = value
      End Set
  End Property</p>
  
  <p>End Class</p></li>
  </ol>
  
  <p>This is the way I think that the ID for the customer object should be exposed, because of the Friend access modifier on the Set the ID for the customer should only be able to be set internally by the framework, and only read externally by the web app or any other app created in the future. But because my code is in seperate class library projects, the MyCompany.MyProject.Repository for example cannot access it even though my Namespaces follow suit.</p>
  
  <p>This doesn't seem to fit my understanding of encapsulation, what am I doing wrong here?</p>
  
  <p>Your help is much appreciated.</p>
  
  <p>Thank you.</p>