title: Software Architecture question. BL creates DTOs differently by type. Is there anything better?
body: <p>I've an application that has three layers:
  1. data layer: exposes Entity Framework entities
  2. business logic layer: queries the EF model, gets entities and should expose DTO (data transfer objects)
  3. UI layer: queries BL, gets DTOs and view them.</p>
  
  <p>Now I've an issue. Different part of my application needs the same DTO but with a little bit different fields. For simplicity suppose that one of my BL classes expose a DTO called Person that is needed with Name and Surname once and with Name and Date Of Birth in other place. </p>
  
  <p>I'd like to hear from you what you think about my simple solution. I've come that is necessary for my UI to agree with BL on a "DTO contract" so that the two layers agree on classes. In my example I would:</p>
  
  <p>a) create an abstract Person class. This class doesn't have any method nor field
  b) create a method in BL called GetPerson that accepts, as parameter, a Person class
  c) define two or more classes that derive from Person (suppose PersonName and PersonDOB)
  d) my UI calls GetPerson passing in the needed type (like GetPerson(typeof(PersonName)))
  e) BL fills in the Person class </p>
  
  <p>What you think about it? Is there any better solution? I think this is not so good buy nothings better comes to my mind.</p>
  
  <p>Thanks a lot.
  Marco</p>