title: Domain services and application services for graphics-based applications
body: <p>I am trying to wrap my head around the domain driven design concept of the service layer, both application services and domain services. Virtually all of the examples I've come across have to do with CRUD applications with databases. I'm having trouble understanding how these concepts map to graphical applications like the example application I've chosen for this question, a clone of Microsoft Paint developed in .NET/C#. </p>
  
  <p>I read the <a href="http://martinfowler.com/eaaCatalog/serviceLayer.html" rel="nofollow noreferrer">basic concept of a service layer in DDD</a> and an <a href="http://www.informit.com/articles/article.aspx?p=1398617&amp;seqNum=4" rel="nofollow noreferrer">expanded explanation</a>. I have chosen the following application layers:</p>
  
  <p>Infrastructure (cross-cutting)</p>
  
  <ul>
  <li>Logging</li>
  </ul>
  
  <p>Data (filesystem)</p>
  
  <ul>
  <li>BitmapImage, PngImage, etc.</li>
  </ul>
  
  <p>Domain</p>
  
  <ul>
  <li>Canvas, Image, Selection, Shape, Brush, etc.</li>
  </ul>
  
  <p>Application</p>
  
  <p>Presentation (local client WPF)</p>
  
  <ul>
  <li>Views</li>
  <li>ViewModels</li>
  </ul>
  
  <p>One use case I'm trying to design is the user drawing a rectangle on the canvas. <a href="https://stackoverflow.com/questions/11878137/service-layer-design-reason-to-put-things-into-a-service-layer">From what I've read</a>, since the use case requires the cooperation of several domain objects a domain service, DrawingService, would make sense.</p>
  
  <p>Another use case would be the user loading a file to be displayed. Again, <a href="http://www.bennadel.com/blog/2385-Application-Services-vs-Infrastructure-Services-vs-Domain-Services.htm" rel="nofollow noreferrer">from what I've read</a>, since this use case is a command and a workflow, an application service, FileLoadingService, would make sense.</p>
  
  <p><a href="http://www.informit.com/articles/article.aspx?p=1398617&amp;seqNum=4" rel="nofollow noreferrer">As Martin Fowler describes</a>, I believe Microsoft Paint is complex enough to warrant a service subsystem, here based on thematic behaviors. However, as the application grows, the service layers could be refactored to fall into partitions of the domain model, e.g. CanvasService, SelectionService, etc. Would than then necessitate another layer of abstraction, <a href="http://msdn.microsoft.com/en-us/library/ee658121.aspx" rel="nofollow noreferrer">perhaps an application facade</a>, now that multiple services must cooperate? </p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>Initial comments suggest DDD architecture is not a good fit for a drawing application. Any suggestions for an alternative?</p>