title: How to handle and organize DTOs for different context?
body: <p>When using simple DTOs in various scenarios I have frequently run into the same kind of problem and I always wondered whether there's a better way to deal with it.</p>
  
  <p>The thing is, I have a business object, e.g. <code>Asset</code> which has a bunch of properties, child objects and calculated fields, some of them expensive to calculate in sense of time, some of them huge in sense of data amonut. I need to use a different flavor of this object in various screens in the UI, e.g. </p>
  
  <ul>
  <li>in a tree where there is a hierarchy displayed and I don't need much more than the display name</li>
  <li>in a grid where I'm showing just a couple of properties</li>
  <li>in a detail pane where there's a big subset of available information, but still some of it (like mapped objects) is shown only on demand</li>
  </ul>
  
  <p>To be able to achieve optimal performance with this scenario, I have always created different DTOs for each context, only containing the subset of information which is actually used in that context. While being a resource-optimal solution, this leads to couple of problems :</p>
  
  <ul>
  <li>I have a class explosion with huge number of DTO classes</li>
  <li>I have quite a hard time coming up with different names for the same thing like <code>AssetDtoForGridInTheOverviewScreenInTheUpperPaneAboveTheSplitter</code>, not to mention maintaining them later</li>
  <li>I am frequently repeating myself in the transformation methods, because there are properties that are used by <strong>most</strong> of the DTOs but not by <strong>all</strong> of them (therefore I can't put them into any superclass and reuse the transformation logic)</li>
  </ul>
  
  <p>The technology I'm using is ASP.NET SOAP WebServices and C# 3.5, but I think somehow this could be a language-agnostic problem. Any ideas are welcome..</p>